src/cx/allocator.h

changeset 1185
d825aca193d3
parent 1180
4c3a69b9723a
child 1188
b0300de92b72
equal deleted inserted replaced
1184:34d60b1664f2 1185:d825aca193d3
130 void *data, 130 void *data,
131 void *memory 131 void *memory
132 ); 132 );
133 133
134 /** 134 /**
135 * Re-allocate a previously allocated block and changes the pointer in-place, 135 * Reallocate a previously allocated block and changes the pointer in-place,
136 * if necessary. 136 * if necessary.
137 * 137 *
138 * @par Error handling 138 * @par Error handling
139 * @c errno will be set by realloc() on failure. 139 * @c errno will be set by realloc() on failure.
140 * 140 *
151 void **mem, 151 void **mem,
152 size_t n 152 size_t n
153 ); 153 );
154 154
155 /** 155 /**
156 * Re-allocate a previously allocated block and changes the pointer in-place, 156 * Reallocate a previously allocated block and changes the pointer in-place,
157 * if necessary. 157 * if necessary.
158 * 158 *
159 * The size is calculated by multiplying @p nemb and @p size. 159 * The size is calculated by multiplying @p nemb and @p size.
160 * 160 *
161 * @par Error handling 161 * @par Error handling
177 size_t nmemb, 177 size_t nmemb,
178 size_t size 178 size_t size
179 ); 179 );
180 180
181 /** 181 /**
182 * Re-allocate a previously allocated block and changes the pointer in-place, 182 * Reallocate a previously allocated block and changes the pointer in-place,
183 * if necessary. 183 * if necessary.
184 * 184 *
185 * @par Error handling 185 * @par Error handling
186 * @c errno will be set by realloc() on failure. 186 * @c errno will be set by realloc() on failure.
187 * 187 *
192 * @see cx_reallocatearray() 192 * @see cx_reallocatearray()
193 */ 193 */
194 #define cx_reallocate(mem, n) cx_reallocate_((void**)(mem), n) 194 #define cx_reallocate(mem, n) cx_reallocate_((void**)(mem), n)
195 195
196 /** 196 /**
197 * Re-allocate a previously allocated block and changes the pointer in-place, 197 * Reallocate a previously allocated block and changes the pointer in-place,
198 * if necessary. 198 * if necessary.
199 * 199 *
200 * The size is calculated by multiplying @p nemb and @p size. 200 * The size is calculated by multiplying @p nemb and @p size.
201 * 201 *
202 * @par Error handling 202 * @par Error handling
244 const CxAllocator *allocator, 244 const CxAllocator *allocator,
245 size_t n 245 size_t n
246 ); 246 );
247 247
248 /** 248 /**
249 * Re-allocate the previously allocated block in @p mem, making the new block 249 * Reallocate the previously allocated block in @p mem, making the new block
250 * @p n bytes long. 250 * @p n bytes long.
251 * This function may return the same pointer that was passed to it, if moving 251 * This function may return the same pointer that was passed to it, if moving
252 * the memory was not necessary. 252 * the memory was not necessary.
253 * 253 *
254 * @note Re-allocating a block allocated by a different allocator is undefined. 254 * @note Re-allocating a block allocated by a different allocator is undefined.
255 * 255 *
256 * @param allocator the allocator 256 * @param allocator the allocator
257 * @param mem pointer to the previously allocated block 257 * @param mem pointer to the previously allocated block
258 * @param n the new size in bytes 258 * @param n the new size in bytes
259 * @return a pointer to the re-allocated memory 259 * @return a pointer to the reallocated memory
260 */ 260 */
261 cx_attr_nodiscard 261 cx_attr_nodiscard
262 cx_attr_nonnull_arg(1) 262 cx_attr_nonnull_arg(1)
263 cx_attr_dealloc_ucx 263 cx_attr_dealloc_ucx
264 cx_attr_allocsize(3) 264 cx_attr_allocsize(3)
268 void *mem, 268 void *mem,
269 size_t n 269 size_t n
270 ); 270 );
271 271
272 /** 272 /**
273 * Re-allocate the previously allocated block in @p mem, making the new block 273 * Reallocate the previously allocated block in @p mem, making the new block
274 * @p n bytes long. 274 * @p n bytes long.
275 * This function may return the same pointer that was passed to it, if moving 275 * This function may return the same pointer that was passed to it, if moving
276 * the memory was not necessary. 276 * the memory was not necessary.
277 * 277 *
278 * The size is calculated by multiplying @p nemb and @p size. 278 * The size is calculated by multiplying @p nemb and @p size.
283 * 283 *
284 * @param allocator the allocator 284 * @param allocator the allocator
285 * @param mem pointer to the previously allocated block 285 * @param mem pointer to the previously allocated block
286 * @param nmemb the number of elements 286 * @param nmemb the number of elements
287 * @param size the size of each element 287 * @param size the size of each element
288 * @return a pointer to the re-allocated memory 288 * @return a pointer to the reallocated memory
289 */ 289 */
290 cx_attr_nodiscard 290 cx_attr_nodiscard
291 cx_attr_nonnull_arg(1) 291 cx_attr_nonnull_arg(1)
292 cx_attr_dealloc_ucx 292 cx_attr_dealloc_ucx
293 cx_attr_allocsize(3, 4) 293 cx_attr_allocsize(3, 4)
298 size_t nmemb, 298 size_t nmemb,
299 size_t size 299 size_t size
300 ); 300 );
301 301
302 /** 302 /**
303 * Re-allocate a previously allocated block and changes the pointer in-place, 303 * Reallocate a previously allocated block and changes the pointer in-place,
304 * if necessary. 304 * if necessary.
305 * This function acts like cxRealloc() using the pointer pointed to by @p mem. 305 * This function acts like cxRealloc() using the pointer pointed to by @p mem.
306 * 306 *
307 * @note Re-allocating a block allocated by a different allocator is undefined. 307 * @note Re-allocating a block allocated by a different allocator is undefined.
308 * 308 *
323 void **mem, 323 void **mem,
324 size_t n 324 size_t n
325 ); 325 );
326 326
327 /** 327 /**
328 * Re-allocate a previously allocated block and changes the pointer in-place, 328 * Reallocate a previously allocated block and changes the pointer in-place,
329 * if necessary. 329 * if necessary.
330 * This function acts like cxRealloc() using the pointer pointed to by @p mem. 330 * This function acts like cxRealloc() using the pointer pointed to by @p mem.
331 * 331 *
332 * @note Re-allocating a block allocated by a different allocator is undefined. 332 * @note Re-allocating a block allocated by a different allocator is undefined.
333 * 333 *
342 */ 342 */
343 #define cxReallocate(allocator, mem, n) \ 343 #define cxReallocate(allocator, mem, n) \
344 cxReallocate_(allocator, (void**)(mem), n) 344 cxReallocate_(allocator, (void**)(mem), n)
345 345
346 /** 346 /**
347 * Re-allocate a previously allocated block and changes the pointer in-place, 347 * Reallocate a previously allocated block and changes the pointer in-place,
348 * if necessary. 348 * if necessary.
349 * This function acts like cxReallocArray() using the pointer pointed to 349 * This function acts like cxReallocArray() using the pointer pointed to
350 * by @p mem. 350 * by @p mem.
351 * 351 *
352 * @note Re-allocating a block allocated by a different allocator is undefined. 352 * @note Re-allocating a block allocated by a different allocator is undefined.
371 size_t nmemb, 371 size_t nmemb,
372 size_t size 372 size_t size
373 ); 373 );
374 374
375 /** 375 /**
376 * Re-allocate a previously allocated block and changes the pointer in-place, 376 * Reallocate a previously allocated block and changes the pointer in-place,
377 * if necessary. 377 * if necessary.
378 * This function acts like cxReallocArray() using the pointer pointed to 378 * This function acts like cxReallocArray() using the pointer pointed to
379 * by @p mem. 379 * by @p mem.
380 * 380 *
381 * @note Re-allocating a block allocated by a different allocator is undefined. 381 * @note Re-allocating a block allocated by a different allocator is undefined.

mercurial