Fri, 23 May 2025 12:44:24 +0200
make test-compile depend on both static and shared
the shared lib is not needed for the tests,
but when run with coverage, gcov will be confused
when outdated line information is available from
a previous shared build
391
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1 | /* |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
3 | * |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
4 | * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved. |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
5 | * |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
8 | * |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
11 | * |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
15 | * |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
27 | */ |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
28 | /** |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
29 | * @file allocator.h |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
30 | * Interface for custom allocators. |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
31 | */ |
391
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
32 | |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
33 | #ifndef UCX_ALLOCATOR_H |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
34 | #define UCX_ALLOCATOR_H |
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
35 | |
484
9e6900b1cf9d
add common.h include to all other header files
Mike Becker <universe@uap-core.de>
parents:
465
diff
changeset
|
36 | #include "common.h" |
391
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
37 | |
415 | 38 | #ifdef __cplusplus |
39 | extern "C" { | |
40 | #endif | |
41 | ||
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
42 | /** |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
43 | * The class definition for an allocator. |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
44 | */ |
396
3539dd99ab92
make cx_allocator_class shared
Mike Becker <universe@uap-core.de>
parents:
394
diff
changeset
|
45 | typedef struct { |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
46 | /** |
465
1e3cb39815f8
remove redundant documentation for function pointers
Mike Becker <universe@uap-core.de>
parents:
461
diff
changeset
|
47 | * The allocator's malloc() implementation. |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
48 | */ |
503
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
49 | void *(*malloc)( |
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
50 | void *data, |
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
51 | size_t n |
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
52 | ); |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
53 | |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
54 | /** |
465
1e3cb39815f8
remove redundant documentation for function pointers
Mike Becker <universe@uap-core.de>
parents:
461
diff
changeset
|
55 | * The allocator's realloc() implementation. |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
56 | */ |
503
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
57 | void *(*realloc)( |
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
58 | void *data, |
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
59 | void *mem, |
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
60 | size_t n |
891
49d8cff6f0ee
make all function attributes leading - fixes #425
Mike Becker <universe@uap-core.de>
parents:
890
diff
changeset
|
61 | ); |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
62 | |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
63 | /** |
465
1e3cb39815f8
remove redundant documentation for function pointers
Mike Becker <universe@uap-core.de>
parents:
461
diff
changeset
|
64 | * The allocator's calloc() implementation. |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
65 | */ |
503
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
66 | void *(*calloc)( |
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
67 | void *data, |
1169
6a33a5648027
add documentation for allocator.h
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
68 | size_t nmemb, |
6a33a5648027
add documentation for allocator.h
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
69 | size_t size |
503
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
70 | ); |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
71 | |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
72 | /** |
465
1e3cb39815f8
remove redundant documentation for function pointers
Mike Becker <universe@uap-core.de>
parents:
461
diff
changeset
|
73 | * The allocator's free() implementation. |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
74 | */ |
503
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
75 | void (*free)( |
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
76 | void *data, |
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
77 | void *mem |
891
49d8cff6f0ee
make all function attributes leading - fixes #425
Mike Becker <universe@uap-core.de>
parents:
890
diff
changeset
|
78 | ); |
396
3539dd99ab92
make cx_allocator_class shared
Mike Becker <universe@uap-core.de>
parents:
394
diff
changeset
|
79 | } cx_allocator_class; |
3539dd99ab92
make cx_allocator_class shared
Mike Becker <universe@uap-core.de>
parents:
394
diff
changeset
|
80 | |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
81 | /** |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
82 | * Structure holding the data for an allocator. |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
83 | */ |
394
80c31ebd66c1
high level allocator functions should be real functions, not macros
Mike Becker <universe@uap-core.de>
parents:
393
diff
changeset
|
84 | struct cx_allocator_s { |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
85 | /** |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
86 | * A pointer to the instance of the allocator class. |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
87 | */ |
396
3539dd99ab92
make cx_allocator_class shared
Mike Becker <universe@uap-core.de>
parents:
394
diff
changeset
|
88 | cx_allocator_class *cl; |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
89 | /** |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
90 | * A pointer to the data this allocator uses. |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
91 | */ |
397
cfc1193b1e65
removes unnecessary cx_allocator typedef
Mike Becker <universe@uap-core.de>
parents:
396
diff
changeset
|
92 | void *data; |
391
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
93 | }; |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
94 | |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
95 | /** |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
96 | * High-Level type alias for the allocator type. |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
97 | */ |
500
eb9e7bd40a8e
do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents:
484
diff
changeset
|
98 | typedef struct cx_allocator_s CxAllocator; |
391
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
99 | |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
100 | /** |
1318
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
101 | * A pre-defined allocator using standard library malloc() etc. |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
102 | */ |
1180
4c3a69b9723a
add support for building windows DLLs - resolves #582
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
103 | cx_attr_export |
1318
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
104 | extern const CxAllocator * const cxStdlibAllocator; |
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
105 | |
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
106 | /** |
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
107 | * The default allocator that is used by UCX. |
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
108 | * Initialized with cxStdlibAllocator, but you may change it. |
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
109 | */ |
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
110 | cx_attr_export |
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
111 | extern const CxAllocator * cxDefaultAllocator; |
391
f094a53c1178
adds allocator interface and default implementation
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
112 | |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
113 | /** |
503
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
114 | * Function pointer type for destructor functions. |
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
115 | * |
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
116 | * A destructor function deallocates possible contents and MAY free the memory |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
117 | * pointed to by @p memory. Read the documentation of the respective function |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
118 | * pointer to learn if a destructor SHALL, MAY, or MUST NOT free the memory in |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
119 | * that particular implementation. |
503
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
120 | * |
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
121 | * @param memory a pointer to the object to destruct |
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
122 | */ |
891
49d8cff6f0ee
make all function attributes leading - fixes #425
Mike Becker <universe@uap-core.de>
parents:
890
diff
changeset
|
123 | typedef void (*cx_destructor_func)(void *memory); |
503
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
124 | |
a89857072ace
add new destructor API and apply it to CxList
Mike Becker <universe@uap-core.de>
parents:
500
diff
changeset
|
125 | /** |
528
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
526
diff
changeset
|
126 | * Function pointer type for destructor functions. |
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
526
diff
changeset
|
127 | * |
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
526
diff
changeset
|
128 | * A destructor function deallocates possible contents and MAY free the memory |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
129 | * pointed to by @p memory. Read the documentation of the respective function |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
130 | * pointer to learn if a destructor SHALL, MAY, or MUST NOT free the memory in |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
131 | * that particular implementation. |
528
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
526
diff
changeset
|
132 | * |
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
526
diff
changeset
|
133 | * @param data an optional pointer to custom data |
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
526
diff
changeset
|
134 | * @param memory a pointer to the object to destruct |
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
526
diff
changeset
|
135 | */ |
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
526
diff
changeset
|
136 | typedef void (*cx_destructor_func2)( |
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
526
diff
changeset
|
137 | void *data, |
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
526
diff
changeset
|
138 | void *memory |
891
49d8cff6f0ee
make all function attributes leading - fixes #425
Mike Becker <universe@uap-core.de>
parents:
890
diff
changeset
|
139 | ); |
528
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
526
diff
changeset
|
140 | |
4fbfac557df8
#179 improve API for list content destruction
Mike Becker <universe@uap-core.de>
parents:
526
diff
changeset
|
141 | /** |
1185
d825aca193d3
use reallocate instead of re-allocate
Mike Becker <universe@uap-core.de>
parents:
1180
diff
changeset
|
142 | * Reallocate a previously allocated block and changes the pointer in-place, |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
143 | * if necessary. |
726
44986c0e2b05
add a low-level stdlib-based cx_reallocate()
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
144 | * |
1318
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
145 | * @note This will use stdlib reallocate and @em not the cxDefaultAllocator. |
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
146 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
147 | * @par Error handling |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
148 | * @c errno will be set by realloc() on failure. |
726
44986c0e2b05
add a low-level stdlib-based cx_reallocate()
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
149 | * |
44986c0e2b05
add a low-level stdlib-based cx_reallocate()
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
150 | * @param mem pointer to the pointer to allocated block |
44986c0e2b05
add a low-level stdlib-based cx_reallocate()
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
151 | * @param n the new size in bytes |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
152 | * @retval zero success |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
153 | * @retval non-zero failure |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
154 | * @see cx_reallocatearray() |
726
44986c0e2b05
add a low-level stdlib-based cx_reallocate()
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
155 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
156 | cx_attr_nonnull |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
157 | cx_attr_nodiscard |
1180
4c3a69b9723a
add support for building windows DLLs - resolves #582
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
158 | cx_attr_export |
1134
60edcd57d54c
fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents:
1087
diff
changeset
|
159 | int cx_reallocate_( |
726
44986c0e2b05
add a low-level stdlib-based cx_reallocate()
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
160 | void **mem, |
44986c0e2b05
add a low-level stdlib-based cx_reallocate()
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
161 | size_t n |
891
49d8cff6f0ee
make all function attributes leading - fixes #425
Mike Becker <universe@uap-core.de>
parents:
890
diff
changeset
|
162 | ); |
726
44986c0e2b05
add a low-level stdlib-based cx_reallocate()
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
163 | |
44986c0e2b05
add a low-level stdlib-based cx_reallocate()
Mike Becker <universe@uap-core.de>
parents:
677
diff
changeset
|
164 | /** |
1185
d825aca193d3
use reallocate instead of re-allocate
Mike Becker <universe@uap-core.de>
parents:
1180
diff
changeset
|
165 | * Reallocate a previously allocated block and changes the pointer in-place, |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
166 | * if necessary. |
935
312fb24c14de
add convenience macro for cx_reallocate to hide the (void**) cast
Mike Becker <universe@uap-core.de>
parents:
891
diff
changeset
|
167 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
168 | * The size is calculated by multiplying @p nemb and @p size. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
169 | * |
1318
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
170 | * @note This will use stdlib reallocate and @em not the cxDefaultAllocator. |
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
171 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
172 | * @par Error handling |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
173 | * @c errno will be set by realloc() on failure or when the multiplication of |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
174 | * @p nmemb and @p size overflows. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
175 | * |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
176 | * @param mem pointer to the pointer to allocated block |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
177 | * @param nmemb the number of elements |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
178 | * @param size the size of each element |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
179 | * @retval zero success |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
180 | * @retval non-zero failure |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
181 | * @see cx_reallocate() |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
182 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
183 | cx_attr_nonnull |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
184 | cx_attr_nodiscard |
1180
4c3a69b9723a
add support for building windows DLLs - resolves #582
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
185 | cx_attr_export |
1134
60edcd57d54c
fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents:
1087
diff
changeset
|
186 | int cx_reallocatearray_( |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
187 | void **mem, |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
188 | size_t nmemb, |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
189 | size_t size |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
190 | ); |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
191 | |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
192 | /** |
1185
d825aca193d3
use reallocate instead of re-allocate
Mike Becker <universe@uap-core.de>
parents:
1180
diff
changeset
|
193 | * Reallocate a previously allocated block and changes the pointer in-place, |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
194 | * if necessary. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
195 | * |
1318
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
196 | * @note This will use stdlib reallocate and @em not the cxDefaultAllocator. |
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
197 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
198 | * @par Error handling |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
199 | * @c errno will be set by realloc() on failure. |
935
312fb24c14de
add convenience macro for cx_reallocate to hide the (void**) cast
Mike Becker <universe@uap-core.de>
parents:
891
diff
changeset
|
200 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
201 | * @param mem (@c void**) pointer to the pointer to allocated block |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
202 | * @param n (@c size_t) the new size in bytes |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
203 | * @retval zero success |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
204 | * @retval non-zero failure |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
205 | * @see cx_reallocatearray() |
935
312fb24c14de
add convenience macro for cx_reallocate to hide the (void**) cast
Mike Becker <universe@uap-core.de>
parents:
891
diff
changeset
|
206 | */ |
1134
60edcd57d54c
fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents:
1087
diff
changeset
|
207 | #define cx_reallocate(mem, n) cx_reallocate_((void**)(mem), n) |
935
312fb24c14de
add convenience macro for cx_reallocate to hide the (void**) cast
Mike Becker <universe@uap-core.de>
parents:
891
diff
changeset
|
208 | |
312fb24c14de
add convenience macro for cx_reallocate to hide the (void**) cast
Mike Becker <universe@uap-core.de>
parents:
891
diff
changeset
|
209 | /** |
1185
d825aca193d3
use reallocate instead of re-allocate
Mike Becker <universe@uap-core.de>
parents:
1180
diff
changeset
|
210 | * Reallocate a previously allocated block and changes the pointer in-place, |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
211 | * if necessary. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
212 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
213 | * The size is calculated by multiplying @p nemb and @p size. |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
214 | * |
1318
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
215 | * @note This will use stdlib reallocate and @em not the cxDefaultAllocator. |
12fa1d37fe48
allow changing the cxDefaultAllocator - resolves #669
Mike Becker <universe@uap-core.de>
parents:
1188
diff
changeset
|
216 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
217 | * @par Error handling |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
218 | * @c errno will be set by realloc() on failure or when the multiplication of |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
219 | * @p nmemb and @p size overflows. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
220 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
221 | * @param mem (@c void**) pointer to the pointer to allocated block |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
222 | * @param nmemb (@c size_t) the number of elements |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
223 | * @param size (@c size_t) the size of each element |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
224 | * @retval zero success |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
225 | * @retval non-zero failure |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
226 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
227 | #define cx_reallocatearray(mem, nmemb, size) \ |
1134
60edcd57d54c
fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents:
1087
diff
changeset
|
228 | cx_reallocatearray_((void**)(mem), nmemb, size) |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
229 | |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
230 | /** |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
231 | * Free a block allocated by this allocator. |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
232 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
233 | * @note Freeing a block of a different allocator is undefined. |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
234 | * |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
235 | * @param allocator the allocator |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
236 | * @param mem a pointer to the block to free |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
237 | */ |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
238 | cx_attr_nonnull_arg(1) |
1180
4c3a69b9723a
add support for building windows DLLs - resolves #582
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
239 | cx_attr_export |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
240 | void cxFree( |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
241 | const CxAllocator *allocator, |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
242 | void *mem |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
243 | ); |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
244 | |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
245 | /** |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
246 | * Allocate @p n bytes of memory. |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
247 | * |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
248 | * @param allocator the allocator |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
249 | * @param n the number of bytes |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
250 | * @return a pointer to the allocated memory |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
251 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
252 | cx_attr_nodiscard |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
253 | cx_attr_nonnull |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
254 | cx_attr_malloc |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
255 | cx_attr_dealloc_ucx |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
256 | cx_attr_allocsize(2) |
1180
4c3a69b9723a
add support for building windows DLLs - resolves #582
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
257 | cx_attr_export |
500
eb9e7bd40a8e
do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents:
484
diff
changeset
|
258 | void *cxMalloc( |
890
54565fd74e74
move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents:
726
diff
changeset
|
259 | const CxAllocator *allocator, |
500
eb9e7bd40a8e
do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents:
484
diff
changeset
|
260 | size_t n |
891
49d8cff6f0ee
make all function attributes leading - fixes #425
Mike Becker <universe@uap-core.de>
parents:
890
diff
changeset
|
261 | ); |
397
cfc1193b1e65
removes unnecessary cx_allocator typedef
Mike Becker <universe@uap-core.de>
parents:
396
diff
changeset
|
262 | |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
263 | /** |
1185
d825aca193d3
use reallocate instead of re-allocate
Mike Becker <universe@uap-core.de>
parents:
1180
diff
changeset
|
264 | * Reallocate the previously allocated block in @p mem, making the new block |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
265 | * @p n bytes long. |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
266 | * This function may return the same pointer that was passed to it, if moving |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
267 | * the memory was not necessary. |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
268 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
269 | * @note Re-allocating a block allocated by a different allocator is undefined. |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
270 | * |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
271 | * @param allocator the allocator |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
272 | * @param mem pointer to the previously allocated block |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
273 | * @param n the new size in bytes |
1185
d825aca193d3
use reallocate instead of re-allocate
Mike Becker <universe@uap-core.de>
parents:
1180
diff
changeset
|
274 | * @return a pointer to the reallocated memory |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
275 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
276 | cx_attr_nodiscard |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
277 | cx_attr_nonnull_arg(1) |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
278 | cx_attr_dealloc_ucx |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
279 | cx_attr_allocsize(3) |
1180
4c3a69b9723a
add support for building windows DLLs - resolves #582
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
280 | cx_attr_export |
500
eb9e7bd40a8e
do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents:
484
diff
changeset
|
281 | void *cxRealloc( |
890
54565fd74e74
move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents:
726
diff
changeset
|
282 | const CxAllocator *allocator, |
500
eb9e7bd40a8e
do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents:
484
diff
changeset
|
283 | void *mem, |
eb9e7bd40a8e
do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents:
484
diff
changeset
|
284 | size_t n |
891
49d8cff6f0ee
make all function attributes leading - fixes #425
Mike Becker <universe@uap-core.de>
parents:
890
diff
changeset
|
285 | ); |
397
cfc1193b1e65
removes unnecessary cx_allocator typedef
Mike Becker <universe@uap-core.de>
parents:
396
diff
changeset
|
286 | |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
287 | /** |
1185
d825aca193d3
use reallocate instead of re-allocate
Mike Becker <universe@uap-core.de>
parents:
1180
diff
changeset
|
288 | * Reallocate the previously allocated block in @p mem, making the new block |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
289 | * @p n bytes long. |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
290 | * This function may return the same pointer that was passed to it, if moving |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
291 | * the memory was not necessary. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
292 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
293 | * The size is calculated by multiplying @p nemb and @p size. |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
294 | * If that multiplication overflows, this function returns @c NULL and @c errno |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
295 | * will be set. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
296 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
297 | * @note Re-allocating a block allocated by a different allocator is undefined. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
298 | * |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
299 | * @param allocator the allocator |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
300 | * @param mem pointer to the previously allocated block |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
301 | * @param nmemb the number of elements |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
302 | * @param size the size of each element |
1185
d825aca193d3
use reallocate instead of re-allocate
Mike Becker <universe@uap-core.de>
parents:
1180
diff
changeset
|
303 | * @return a pointer to the reallocated memory |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
304 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
305 | cx_attr_nodiscard |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
306 | cx_attr_nonnull_arg(1) |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
307 | cx_attr_dealloc_ucx |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
308 | cx_attr_allocsize(3, 4) |
1180
4c3a69b9723a
add support for building windows DLLs - resolves #582
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
309 | cx_attr_export |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
310 | void *cxReallocArray( |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
311 | const CxAllocator *allocator, |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
312 | void *mem, |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
313 | size_t nmemb, |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
314 | size_t size |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
315 | ); |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
316 | |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
317 | /** |
1185
d825aca193d3
use reallocate instead of re-allocate
Mike Becker <universe@uap-core.de>
parents:
1180
diff
changeset
|
318 | * Reallocate a previously allocated block and changes the pointer in-place, |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
319 | * if necessary. |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
320 | * This function acts like cxRealloc() using the pointer pointed to by @p mem. |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
321 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
322 | * @note Re-allocating a block allocated by a different allocator is undefined. |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
323 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
324 | * @par Error handling |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
325 | * @c errno will be set, if the underlying realloc function does so. |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
326 | * |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
327 | * @param allocator the allocator |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
328 | * @param mem pointer to the pointer to allocated block |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
329 | * @param n the new size in bytes |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
330 | * @retval zero success |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
331 | * @retval non-zero failure |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
332 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
333 | cx_attr_nodiscard |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
334 | cx_attr_nonnull |
1180
4c3a69b9723a
add support for building windows DLLs - resolves #582
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
335 | cx_attr_export |
1134
60edcd57d54c
fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents:
1087
diff
changeset
|
336 | int cxReallocate_( |
890
54565fd74e74
move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents:
726
diff
changeset
|
337 | const CxAllocator *allocator, |
500
eb9e7bd40a8e
do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents:
484
diff
changeset
|
338 | void **mem, |
eb9e7bd40a8e
do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents:
484
diff
changeset
|
339 | size_t n |
891
49d8cff6f0ee
make all function attributes leading - fixes #425
Mike Becker <universe@uap-core.de>
parents:
890
diff
changeset
|
340 | ); |
414 | 341 | |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
342 | /** |
1185
d825aca193d3
use reallocate instead of re-allocate
Mike Becker <universe@uap-core.de>
parents:
1180
diff
changeset
|
343 | * Reallocate a previously allocated block and changes the pointer in-place, |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
344 | * if necessary. |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
345 | * This function acts like cxRealloc() using the pointer pointed to by @p mem. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
346 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
347 | * @note Re-allocating a block allocated by a different allocator is undefined. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
348 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
349 | * @par Error handling |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
350 | * @c errno will be set, if the underlying realloc function does so. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
351 | * |
1087
128324af5164
don't document constness of arguments in macros
Mike Becker <universe@uap-core.de>
parents:
1085
diff
changeset
|
352 | * @param allocator (@c CxAllocator*) the allocator |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
353 | * @param mem (@c void**) pointer to the pointer to allocated block |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
354 | * @param n (@c size_t) the new size in bytes |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
355 | * @retval zero success |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
356 | * @retval non-zero failure |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
357 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
358 | #define cxReallocate(allocator, mem, n) \ |
1134
60edcd57d54c
fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents:
1087
diff
changeset
|
359 | cxReallocate_(allocator, (void**)(mem), n) |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
360 | |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
361 | /** |
1185
d825aca193d3
use reallocate instead of re-allocate
Mike Becker <universe@uap-core.de>
parents:
1180
diff
changeset
|
362 | * Reallocate a previously allocated block and changes the pointer in-place, |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
363 | * if necessary. |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
364 | * This function acts like cxReallocArray() using the pointer pointed to |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
365 | * by @p mem. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
366 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
367 | * @note Re-allocating a block allocated by a different allocator is undefined. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
368 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
369 | * @par Error handling |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
370 | * @c errno will be set, if the underlying realloc function does so or the |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
371 | * multiplication of @p nmemb and @p size overflows. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
372 | * |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
373 | * @param allocator the allocator |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
374 | * @param mem pointer to the pointer to allocated block |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
375 | * @param nmemb the number of elements |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
376 | * @param size the size of each element |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
377 | * @retval zero success |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
378 | * @retval non-zero on failure |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
379 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
380 | cx_attr_nodiscard |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
381 | cx_attr_nonnull |
1180
4c3a69b9723a
add support for building windows DLLs - resolves #582
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
382 | cx_attr_export |
1134
60edcd57d54c
fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents:
1087
diff
changeset
|
383 | int cxReallocateArray_( |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
384 | const CxAllocator *allocator, |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
385 | void **mem, |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
386 | size_t nmemb, |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
387 | size_t size |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
388 | ); |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
389 | |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
390 | /** |
1185
d825aca193d3
use reallocate instead of re-allocate
Mike Becker <universe@uap-core.de>
parents:
1180
diff
changeset
|
391 | * Reallocate a previously allocated block and changes the pointer in-place, |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
392 | * if necessary. |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
393 | * This function acts like cxReallocArray() using the pointer pointed to |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
394 | * by @p mem. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
395 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
396 | * @note Re-allocating a block allocated by a different allocator is undefined. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
397 | * |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
398 | * @par Error handling |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
399 | * @c errno will be set, if the underlying realloc function does so or the |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
400 | * multiplication of @p nmemb and @p size overflows. |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
401 | * |
1087
128324af5164
don't document constness of arguments in macros
Mike Becker <universe@uap-core.de>
parents:
1085
diff
changeset
|
402 | * @param allocator (@c CxAllocator*) the allocator |
1085
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
403 | * @param mem (@c void**) pointer to the pointer to allocated block |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
404 | * @param nmemb (@c size_t) the number of elements |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
405 | * @param size (@c size_t) the size of each element |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
406 | * @retval zero success |
b8e0b4130cc3
refine docs for allocator.h - issue #548
Mike Becker <universe@uap-core.de>
parents:
985
diff
changeset
|
407 | * @retval non-zero failure |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
408 | */ |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
409 | #define cxReallocateArray(allocator, mem, nmemb, size) \ |
1134
60edcd57d54c
fix that some IDEs cannot resolve documentation
Mike Becker <universe@uap-core.de>
parents:
1087
diff
changeset
|
410 | cxReallocateArray_(allocator, (void**) (mem), nmemb, size) |
963
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
411 | |
2f601274bbac
add reallocarray() like functions - resolves #468
Mike Becker <universe@uap-core.de>
parents:
935
diff
changeset
|
412 | /** |
1169
6a33a5648027
add documentation for allocator.h
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
413 | * Allocate @p nmemb elements of @p n bytes each, all initialized to zero. |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
414 | * |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
415 | * @param allocator the allocator |
1169
6a33a5648027
add documentation for allocator.h
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
416 | * @param nmemb the number of elements |
6a33a5648027
add documentation for allocator.h
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
417 | * @param size the size of each element in bytes |
429
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
418 | * @return a pointer to the allocated memory |
3d8235c96a27
add documentation to allocator.h
Mike Becker <universe@uap-core.de>
parents:
419
diff
changeset
|
419 | */ |
985
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
420 | cx_attr_nonnull_arg(1) |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
421 | cx_attr_nodiscard |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
422 | cx_attr_malloc |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
423 | cx_attr_dealloc_ucx |
68754c7de906
major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents:
963
diff
changeset
|
424 | cx_attr_allocsize(2, 3) |
1180
4c3a69b9723a
add support for building windows DLLs - resolves #582
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
425 | cx_attr_export |
500
eb9e7bd40a8e
do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents:
484
diff
changeset
|
426 | void *cxCalloc( |
890
54565fd74e74
move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents:
726
diff
changeset
|
427 | const CxAllocator *allocator, |
1169
6a33a5648027
add documentation for allocator.h
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
428 | size_t nmemb, |
6a33a5648027
add documentation for allocator.h
Mike Becker <universe@uap-core.de>
parents:
1134
diff
changeset
|
429 | size_t size |
891
49d8cff6f0ee
make all function attributes leading - fixes #425
Mike Becker <universe@uap-core.de>
parents:
890
diff
changeset
|
430 | ); |
397
cfc1193b1e65
removes unnecessary cx_allocator typedef
Mike Becker <universe@uap-core.de>
parents:
396
diff
changeset
|
431 | |
1319
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
432 | |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
433 | |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
434 | /** |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
435 | * Convenience macro that invokes cxMalloc() with the cxDefaultAllocator. |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
436 | */ |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
437 | #define cxMallocDefault(...) cxMalloc(cxDefaultAllocator, __VA_ARGS__) |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
438 | /** |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
439 | * Convenience macro that invokes cxCalloc() with the cxDefaultAllocator. |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
440 | */ |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
441 | #define cxCallocDefault(...) cxCalloc(cxDefaultAllocator, __VA_ARGS__) |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
442 | /** |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
443 | * Convenience macro that invokes cxRealloc() with the cxDefaultAllocator. |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
444 | */ |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
445 | #define cxReallocDefault(...) cxRealloc(cxDefaultAllocator, __VA_ARGS__) |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
446 | /** |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
447 | * Convenience macro that invokes cxReallocate() with the cxDefaultAllocator. |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
448 | */ |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
449 | #define cxReallocateDefault(...) cxReallocate(cxDefaultAllocator, __VA_ARGS__) |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
450 | /** |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
451 | * Convenience macro that invokes cxReallocateArray() with the cxDefaultAllocator. |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
452 | */ |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
453 | #define cxReallocateArrayDefault(...) cxReallocateArray(cxDefaultAllocator, __VA_ARGS__) |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
454 | /** |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
455 | * Convenience macro that invokes cxReallocArray() with the cxDefaultAllocator. |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
456 | */ |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
457 | #define cxReallocArrayDefault(...) cxReallocArray(cxDefaultAllocator, __VA_ARGS__) |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
458 | /** |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
459 | * Convenience macro that invokes cxFree() with the cxDefaultAllocator. |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
460 | */ |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
461 | #define cxFreeDefault(...) cxFree(cxDefaultAllocator, __VA_ARGS__) |
aa1f580f8f59
add convenience macros for using the default allocator - relates to #669
Mike Becker <universe@uap-core.de>
parents:
1318
diff
changeset
|
462 | |
415 | 463 | #ifdef __cplusplus |
628
1e2be40f0cb5
use //-style single line comments everywhere
Mike Becker <universe@uap-core.de>
parents:
528
diff
changeset
|
464 | } // extern "C" |
415 | 465 | #endif |
466 | ||
628
1e2be40f0cb5
use //-style single line comments everywhere
Mike Becker <universe@uap-core.de>
parents:
528
diff
changeset
|
467 | #endif // UCX_ALLOCATOR_H |