src/cx/allocator.h

changeset 890
54565fd74e74
parent 726
44986c0e2b05
child 891
49d8cff6f0ee
equal deleted inserted replaced
889:f549fd9fbd8f 890:54565fd74e74
154 * @param allocator the allocator 154 * @param allocator the allocator
155 * @param n the number of bytes 155 * @param n the number of bytes
156 * @return a pointer to the allocated memory 156 * @return a pointer to the allocated memory
157 */ 157 */
158 void *cxMalloc( 158 void *cxMalloc(
159 CxAllocator const *allocator, 159 const CxAllocator *allocator,
160 size_t n 160 size_t n
161 ) 161 )
162 __attribute__((__malloc__)) 162 __attribute__((__malloc__))
163 __attribute__((__alloc_size__(2))); 163 __attribute__((__alloc_size__(2)));
164 164
173 * @param mem pointer to the previously allocated block 173 * @param mem pointer to the previously allocated block
174 * @param n the new size in bytes 174 * @param n the new size in bytes
175 * @return a pointer to the re-allocated memory 175 * @return a pointer to the re-allocated memory
176 */ 176 */
177 void *cxRealloc( 177 void *cxRealloc(
178 CxAllocator const *allocator, 178 const CxAllocator *allocator,
179 void *mem, 179 void *mem,
180 size_t n 180 size_t n
181 ) 181 )
182 __attribute__((__warn_unused_result__)) 182 __attribute__((__warn_unused_result__))
183 __attribute__((__alloc_size__(3))); 183 __attribute__((__alloc_size__(3)));
195 * @param mem pointer to the pointer to allocated block 195 * @param mem pointer to the pointer to allocated block
196 * @param n the new size in bytes 196 * @param n the new size in bytes
197 * @return zero on success, non-zero on failure 197 * @return zero on success, non-zero on failure
198 */ 198 */
199 int cxReallocate( 199 int cxReallocate(
200 CxAllocator const *allocator, 200 const CxAllocator *allocator,
201 void **mem, 201 void **mem,
202 size_t n 202 size_t n
203 ) 203 )
204 __attribute__((__nonnull__)); 204 __attribute__((__nonnull__));
205 205
210 * @param nelem the number of elements 210 * @param nelem the number of elements
211 * @param n the size of each element in bytes 211 * @param n the size of each element in bytes
212 * @return a pointer to the allocated memory 212 * @return a pointer to the allocated memory
213 */ 213 */
214 void *cxCalloc( 214 void *cxCalloc(
215 CxAllocator const *allocator, 215 const CxAllocator *allocator,
216 size_t nelem, 216 size_t nelem,
217 size_t n 217 size_t n
218 ) 218 )
219 __attribute__((__malloc__)) 219 __attribute__((__malloc__))
220 __attribute__((__alloc_size__(2, 3))); 220 __attribute__((__alloc_size__(2, 3)));
226 * 226 *
227 * @param allocator the allocator 227 * @param allocator the allocator
228 * @param mem a pointer to the block to free 228 * @param mem a pointer to the block to free
229 */ 229 */
230 void cxFree( 230 void cxFree(
231 CxAllocator const *allocator, 231 const CxAllocator *allocator,
232 void *mem 232 void *mem
233 ) 233 )
234 __attribute__((__nonnull__)); 234 __attribute__((__nonnull__));
235 235
236 #ifdef __cplusplus 236 #ifdef __cplusplus

mercurial