src/cx/allocator.h

changeset 1134
60edcd57d54c
parent 1087
128324af5164
equal deleted inserted replaced
1133:0aecb9fda851 1134:60edcd57d54c
143 * @retval non-zero failure 143 * @retval non-zero failure
144 * @see cx_reallocatearray() 144 * @see cx_reallocatearray()
145 */ 145 */
146 cx_attr_nonnull 146 cx_attr_nonnull
147 cx_attr_nodiscard 147 cx_attr_nodiscard
148 int cx_reallocate( 148 int cx_reallocate_(
149 void **mem, 149 void **mem,
150 size_t n 150 size_t n
151 ); 151 );
152 152
153 /** 153 /**
167 * @retval non-zero failure 167 * @retval non-zero failure
168 * @see cx_reallocate() 168 * @see cx_reallocate()
169 */ 169 */
170 cx_attr_nonnull 170 cx_attr_nonnull
171 cx_attr_nodiscard 171 cx_attr_nodiscard
172 int cx_reallocatearray( 172 int cx_reallocatearray_(
173 void **mem, 173 void **mem,
174 size_t nmemb, 174 size_t nmemb,
175 size_t size 175 size_t size
176 ); 176 );
177 177
186 * @param n (@c size_t) the new size in bytes 186 * @param n (@c size_t) the new size in bytes
187 * @retval zero success 187 * @retval zero success
188 * @retval non-zero failure 188 * @retval non-zero failure
189 * @see cx_reallocatearray() 189 * @see cx_reallocatearray()
190 */ 190 */
191 #define cx_reallocate(mem, n) cx_reallocate((void**)(mem), n) 191 #define cx_reallocate(mem, n) cx_reallocate_((void**)(mem), n)
192 192
193 /** 193 /**
194 * Re-allocate a previously allocated block and changes the pointer in-place, 194 * Re-allocate a previously allocated block and changes the pointer in-place,
195 * if necessary. 195 * if necessary.
196 * 196 *
205 * @param size (@c size_t) the size of each element 205 * @param size (@c size_t) the size of each element
206 * @retval zero success 206 * @retval zero success
207 * @retval non-zero failure 207 * @retval non-zero failure
208 */ 208 */
209 #define cx_reallocatearray(mem, nmemb, size) \ 209 #define cx_reallocatearray(mem, nmemb, size) \
210 cx_reallocatearray((void**)(mem), nmemb, size) 210 cx_reallocatearray_((void**)(mem), nmemb, size)
211 211
212 /** 212 /**
213 * Free a block allocated by this allocator. 213 * Free a block allocated by this allocator.
214 * 214 *
215 * @note Freeing a block of a different allocator is undefined. 215 * @note Freeing a block of a different allocator is undefined.
308 * @retval zero success 308 * @retval zero success
309 * @retval non-zero failure 309 * @retval non-zero failure
310 */ 310 */
311 cx_attr_nodiscard 311 cx_attr_nodiscard
312 cx_attr_nonnull 312 cx_attr_nonnull
313 int cxReallocate( 313 int cxReallocate_(
314 const CxAllocator *allocator, 314 const CxAllocator *allocator,
315 void **mem, 315 void **mem,
316 size_t n 316 size_t n
317 ); 317 );
318 318
331 * @param n (@c size_t) the new size in bytes 331 * @param n (@c size_t) the new size in bytes
332 * @retval zero success 332 * @retval zero success
333 * @retval non-zero failure 333 * @retval non-zero failure
334 */ 334 */
335 #define cxReallocate(allocator, mem, n) \ 335 #define cxReallocate(allocator, mem, n) \
336 cxReallocate(allocator, (void**)(mem), n) 336 cxReallocate_(allocator, (void**)(mem), n)
337 337
338 /** 338 /**
339 * Re-allocate a previously allocated block and changes the pointer in-place, 339 * Re-allocate a previously allocated block and changes the pointer in-place,
340 * if necessary. 340 * if necessary.
341 * This function acts like cxReallocArray() using the pointer pointed to 341 * This function acts like cxReallocArray() using the pointer pointed to
354 * @retval zero success 354 * @retval zero success
355 * @retval non-zero on failure 355 * @retval non-zero on failure
356 */ 356 */
357 cx_attr_nodiscard 357 cx_attr_nodiscard
358 cx_attr_nonnull 358 cx_attr_nonnull
359 int cxReallocateArray( 359 int cxReallocateArray_(
360 const CxAllocator *allocator, 360 const CxAllocator *allocator,
361 void **mem, 361 void **mem,
362 size_t nmemb, 362 size_t nmemb,
363 size_t size 363 size_t size
364 ); 364 );
381 * @param size (@c size_t) the size of each element 381 * @param size (@c size_t) the size of each element
382 * @retval zero success 382 * @retval zero success
383 * @retval non-zero failure 383 * @retval non-zero failure
384 */ 384 */
385 #define cxReallocateArray(allocator, mem, nmemb, size) \ 385 #define cxReallocateArray(allocator, mem, nmemb, size) \
386 cxReallocateArray(allocator, (void**) (mem), nmemb, size) 386 cxReallocateArray_(allocator, (void**) (mem), nmemb, size)
387 387
388 /** 388 /**
389 * Allocate @p nelem elements of @p n bytes each, all initialized to zero. 389 * Allocate @p nelem elements of @p n bytes each, all initialized to zero.
390 * 390 *
391 * @param allocator the allocator 391 * @param allocator the allocator

mercurial