src/cx/allocator.h

changeset 461
005c2791c2e2
parent 452
a10c3e127050
child 465
1e3cb39815f8
equal deleted inserted replaced
460:e075009b33b7 461:005c2791c2e2
119 * @param allocator the allocator 119 * @param allocator the allocator
120 * @param n the number of bytes 120 * @param n the number of bytes
121 * @return a pointer to the allocated memory 121 * @return a pointer to the allocated memory
122 */ 122 */
123 void *cxMalloc(CxAllocator allocator, size_t n) 123 void *cxMalloc(CxAllocator allocator, size_t n)
124 __attribute__((__malloc__, __alloc_size__(2))); 124 __attribute__((__malloc__))
125 __attribute__((__alloc_size__(2)));
125 126
126 /** 127 /**
127 * Re-allocate the previously allocated block in \p mem, making the new block \p n bytes long. 128 * Re-allocate the previously allocated block in \p mem, making the new block \p n bytes long.
128 * This function may return the same pointer that was passed to it, if moving the memory 129 * This function may return the same pointer that was passed to it, if moving the memory
129 * was not necessary. 130 * was not necessary.
134 * @param mem pointer to the previously allocated block 135 * @param mem pointer to the previously allocated block
135 * @param n the new size in bytes 136 * @param n the new size in bytes
136 * @return a pointer to the re-allocated memory 137 * @return a pointer to the re-allocated memory
137 */ 138 */
138 void *cxRealloc(CxAllocator allocator, void *mem, size_t n) 139 void *cxRealloc(CxAllocator allocator, void *mem, size_t n)
139 __attribute__((__warn_unused_result__, __alloc_size__(3))); 140 __attribute__((__warn_unused_result__))
141 __attribute__((__alloc_size__(3)));
140 142
141 /** 143 /**
142 * Re-allocate a previously allocated block and changes the pointer in-place, if necessary. 144 * Re-allocate a previously allocated block and changes the pointer in-place, if necessary.
143 * This function acts like cxRealloc() using the pointer pointed to by \p mem. 145 * This function acts like cxRealloc() using the pointer pointed to by \p mem.
144 * On success, the pointer is changed to the new location (in case the 146 * On success, the pointer is changed to the new location (in case the
163 * @param nelem the number of elements 165 * @param nelem the number of elements
164 * @param n the size of each element in bytes 166 * @param n the size of each element in bytes
165 * @return a pointer to the allocated memory 167 * @return a pointer to the allocated memory
166 */ 168 */
167 void *cxCalloc(CxAllocator allocator, size_t nelem, size_t n) 169 void *cxCalloc(CxAllocator allocator, size_t nelem, size_t n)
168 __attribute__((__malloc__, __alloc_size__(2, 3))); 170 __attribute__((__malloc__))
171 __attribute__((__alloc_size__(2, 3)));
169 172
170 /** 173 /**
171 * Free a block allocated by this allocator. 174 * Free a block allocated by this allocator.
172 * 175 *
173 * \note Freeing a block of a different allocator is undefined. 176 * \note Freeing a block of a different allocator is undefined.

mercurial