| 183 int cxReallocate_( |
193 int cxReallocate_( |
| 184 const CxAllocator *allocator, |
194 const CxAllocator *allocator, |
| 185 void **mem, |
195 void **mem, |
| 186 size_t n |
196 size_t n |
| 187 ) { |
197 ) { |
| |
198 if (n == 0) { |
| |
199 cxFree(allocator, *mem); |
| |
200 *mem = NULL; |
| |
201 return 0; |
| |
202 } |
| 188 void *nmem = allocator->cl->realloc(allocator->data, *mem, n); |
203 void *nmem = allocator->cl->realloc(allocator->data, *mem, n); |
| 189 if (nmem == NULL) { |
204 if (nmem == NULL) { |
| 190 return 1; // LCOV_EXCL_LINE |
205 return 1; // LCOV_EXCL_LINE |
| 191 } else { |
206 } else { |
| 192 *mem = nmem; |
207 *mem = nmem; |
| 198 const CxAllocator *allocator, |
213 const CxAllocator *allocator, |
| 199 void **mem, |
214 void **mem, |
| 200 size_t nmemb, |
215 size_t nmemb, |
| 201 size_t size |
216 size_t size |
| 202 ) { |
217 ) { |
| |
218 if (nmemb == 0 || size == 0) { |
| |
219 cxFree(allocator, *mem); |
| |
220 *mem = NULL; |
| |
221 return 0; |
| |
222 } |
| 203 void *nmem = cxReallocArray(allocator, *mem, nmemb, size); |
223 void *nmem = cxReallocArray(allocator, *mem, nmemb, size); |
| 204 if (nmem == NULL) { |
224 if (nmem == NULL) { |
| 205 return 1; // LCOV_EXCL_LINE |
225 return 1; // LCOV_EXCL_LINE |
| 206 } else { |
226 } else { |
| 207 *mem = nmem; |
227 *mem = nmem; |