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) |
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. |