96 * High-Level type alias for the allocator type. |
96 * High-Level type alias for the allocator type. |
97 */ |
97 */ |
98 typedef struct cx_allocator_s CxAllocator; |
98 typedef struct cx_allocator_s CxAllocator; |
99 |
99 |
100 /** |
100 /** |
101 * A default allocator using standard library malloc() etc. |
101 * A pre-defined allocator using standard library malloc() etc. |
102 */ |
102 */ |
103 cx_attr_export |
103 cx_attr_export |
104 extern const CxAllocator * const cxDefaultAllocator; |
104 extern const CxAllocator * const cxStdlibAllocator; |
|
105 |
|
106 /** |
|
107 * The default allocator that is used by UCX. |
|
108 * Initialized with cxStdlibAllocator, but you may change it. |
|
109 */ |
|
110 cx_attr_export |
|
111 extern const CxAllocator * cxDefaultAllocator; |
105 |
112 |
106 /** |
113 /** |
107 * Function pointer type for destructor functions. |
114 * Function pointer type for destructor functions. |
108 * |
115 * |
109 * A destructor function deallocates possible contents and MAY free the memory |
116 * A destructor function deallocates possible contents and MAY free the memory |
133 |
140 |
134 /** |
141 /** |
135 * Reallocate a previously allocated block and changes the pointer in-place, |
142 * Reallocate a previously allocated block and changes the pointer in-place, |
136 * if necessary. |
143 * if necessary. |
137 * |
144 * |
|
145 * @note This will use stdlib reallocate and @em not the cxDefaultAllocator. |
|
146 * |
138 * @par Error handling |
147 * @par Error handling |
139 * @c errno will be set by realloc() on failure. |
148 * @c errno will be set by realloc() on failure. |
140 * |
149 * |
141 * @param mem pointer to the pointer to allocated block |
150 * @param mem pointer to the pointer to allocated block |
142 * @param n the new size in bytes |
151 * @param n the new size in bytes |
155 /** |
164 /** |
156 * Reallocate a previously allocated block and changes the pointer in-place, |
165 * Reallocate a previously allocated block and changes the pointer in-place, |
157 * if necessary. |
166 * if necessary. |
158 * |
167 * |
159 * The size is calculated by multiplying @p nemb and @p size. |
168 * The size is calculated by multiplying @p nemb and @p size. |
|
169 * |
|
170 * @note This will use stdlib reallocate and @em not the cxDefaultAllocator. |
160 * |
171 * |
161 * @par Error handling |
172 * @par Error handling |
162 * @c errno will be set by realloc() on failure or when the multiplication of |
173 * @c errno will be set by realloc() on failure or when the multiplication of |
163 * @p nmemb and @p size overflows. |
174 * @p nmemb and @p size overflows. |
164 * |
175 * |
180 |
191 |
181 /** |
192 /** |
182 * Reallocate a previously allocated block and changes the pointer in-place, |
193 * Reallocate a previously allocated block and changes the pointer in-place, |
183 * if necessary. |
194 * if necessary. |
184 * |
195 * |
|
196 * @note This will use stdlib reallocate and @em not the cxDefaultAllocator. |
|
197 * |
185 * @par Error handling |
198 * @par Error handling |
186 * @c errno will be set by realloc() on failure. |
199 * @c errno will be set by realloc() on failure. |
187 * |
200 * |
188 * @param mem (@c void**) pointer to the pointer to allocated block |
201 * @param mem (@c void**) pointer to the pointer to allocated block |
189 * @param n (@c size_t) the new size in bytes |
202 * @param n (@c size_t) the new size in bytes |
196 /** |
209 /** |
197 * Reallocate a previously allocated block and changes the pointer in-place, |
210 * Reallocate a previously allocated block and changes the pointer in-place, |
198 * if necessary. |
211 * if necessary. |
199 * |
212 * |
200 * The size is calculated by multiplying @p nemb and @p size. |
213 * The size is calculated by multiplying @p nemb and @p size. |
|
214 * |
|
215 * @note This will use stdlib reallocate and @em not the cxDefaultAllocator. |
201 * |
216 * |
202 * @par Error handling |
217 * @par Error handling |
203 * @c errno will be set by realloc() on failure or when the multiplication of |
218 * @c errno will be set by realloc() on failure or when the multiplication of |
204 * @p nmemb and @p size overflows. |
219 * @p nmemb and @p size overflows. |
205 * |
220 * |