src/cx/allocator.h

changeset 508
8aea65ae1eaf
parent 503
a89857072ace
child 526
b070ef465313
equal deleted inserted replaced
507:2e8878770de0 508:8aea65ae1eaf
122 * @param allocator the allocator 122 * @param allocator the allocator
123 * @param n the number of bytes 123 * @param n the number of bytes
124 * @return a pointer to the allocated memory 124 * @return a pointer to the allocated memory
125 */ 125 */
126 void *cxMalloc( 126 void *cxMalloc(
127 CxAllocator *allocator, 127 CxAllocator const *allocator,
128 size_t n 128 size_t n
129 ) 129 )
130 __attribute__((__malloc__)) 130 __attribute__((__malloc__))
131 __attribute__((__alloc_size__(2))); 131 __attribute__((__alloc_size__(2)));
132 132
141 * @param mem pointer to the previously allocated block 141 * @param mem pointer to the previously allocated block
142 * @param n the new size in bytes 142 * @param n the new size in bytes
143 * @return a pointer to the re-allocated memory 143 * @return a pointer to the re-allocated memory
144 */ 144 */
145 void *cxRealloc( 145 void *cxRealloc(
146 CxAllocator *allocator, 146 CxAllocator const *allocator,
147 void *mem, 147 void *mem,
148 size_t n 148 size_t n
149 ) 149 )
150 __attribute__((__warn_unused_result__)) 150 __attribute__((__warn_unused_result__))
151 __attribute__((__alloc_size__(3))); 151 __attribute__((__alloc_size__(3)));
164 * @param mem pointer to the pointer to allocated block 164 * @param mem pointer to the pointer to allocated block
165 * @param n the new size in bytes 165 * @param n the new size in bytes
166 * @return zero on success, non-zero on failure 166 * @return zero on success, non-zero on failure
167 */ 167 */
168 int cxReallocate( 168 int cxReallocate(
169 CxAllocator *allocator, 169 CxAllocator const *allocator,
170 void **mem, 170 void **mem,
171 size_t n 171 size_t n
172 ) 172 )
173 __attribute__((__nonnull__)); 173 __attribute__((__nonnull__));
174 174
179 * @param nelem the number of elements 179 * @param nelem the number of elements
180 * @param n the size of each element in bytes 180 * @param n the size of each element in bytes
181 * @return a pointer to the allocated memory 181 * @return a pointer to the allocated memory
182 */ 182 */
183 void *cxCalloc( 183 void *cxCalloc(
184 CxAllocator *allocator, 184 CxAllocator const *allocator,
185 size_t nelem, 185 size_t nelem,
186 size_t n 186 size_t n
187 ) 187 )
188 __attribute__((__malloc__)) 188 __attribute__((__malloc__))
189 __attribute__((__alloc_size__(2, 3))); 189 __attribute__((__alloc_size__(2, 3)));
195 * 195 *
196 * @param allocator the allocator 196 * @param allocator the allocator
197 * @param mem a pointer to the block to free 197 * @param mem a pointer to the block to free
198 */ 198 */
199 void cxFree( 199 void cxFree(
200 CxAllocator *allocator, 200 CxAllocator const *allocator,
201 void *mem 201 void *mem
202 ) 202 )
203 __attribute__((__nonnull__)); 203 __attribute__((__nonnull__));
204 204
205 #ifdef __cplusplus 205 #ifdef __cplusplus

mercurial