MCPcopy Create free account
hub / github.com/acl-dev/acl / acl_default_realloc

Function acl_default_realloc

lib_acl/src/stdlib/memory/acl_default_malloc.c:251–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249/* acl_default_realloc - reallocate memory or bust */
250
251void *acl_default_realloc(const char *filename, int line,
252 void *ptr, size_t len)
253{
254 const char *myname = "acl_default_realloc";
255 MBLOCK *real_ptr;
256 size_t old_len, new_len;
257 const char *pname = NULL;
258
259 if (filename && *filename) {
260 SET_FILE(pname, filename);
261 } else {
262 pname = __FILENAME_UNKNOWN;
263 }
264
265#ifndef NO_SHARED_EMPTY_STRINGS
266 if (ptr == empty_string) {
267 return acl_default_malloc(pname, line, len);
268 }
269#endif
270
271 if (len < 1) {
272 acl_msg_warn("%s(%d)->%s: realloc: requested length %ld",
273 pname, line, myname, (long) len);
274 acl_trace_info();
275 len = 128;
276 }
277
278 if (ptr == NULL) {
279 return acl_default_malloc(pname, line, len);
280 }
281
282 CHECK_IN_PTR(ptr, real_ptr, old_len, pname, line);
283
284 new_len = SPACE_FOR(len);
285 if (new_len <= 0) {
286 acl_msg_fatal("%s(%d): new_len(%d) <= 0",
287 myname, __LINE__, (int) new_len);
288 } else if (new_len >= __malloc_limit) {
289 acl_msg_warn("%s(%d): new_len(%d) too large",
290 myname, __LINE__, (int) new_len);
291 acl_trace_info();
292 }
293
294#ifdef DEBUG_MEM
295 if (ptr)
296 __nrealloc++;
297 else
298 __nmalloc++;
299 __nsize += len;
300 __nsize -= old_len;
301#endif
302
303#ifdef _USE_GLIB
304 if ((real_ptr = (MBLOCK *) g_realloc((char *) real_ptr, new_len)) == 0) {
305 acl_msg_fatal("%s(%d)->%s: realloc: insufficient memory: %s",
306 pname, line, myname, strerror(errno));
307 }
308#else

Callers 1

stack_growFunction · 0.85

Calls 5

acl_default_mallocFunction · 0.85
acl_msg_warnFunction · 0.85
acl_trace_infoFunction · 0.85
acl_msg_fatalFunction · 0.85
reallocFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…