void *sm_xrealloc(char *fname, int lineno, void *ptr, size_t size) { void *buf; buf = sm_realloc(fname, lineno, ptr, size); if (buf == NULL) nomem(fname, lineno, size); return buf; }
void *brealloc (void *buf, size_t size) { #ifdef SMARTALOC buf = sm_realloc(__FILE__, __LINE__, buf, size); #else buf = realloc(buf, size); #endif if (buf == NULL) { berrno be; Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s\n"), be.bstrerror()); } return buf; }
/* Realloc pool memory buffer */ POOLMEM *sm_realloc_pool_memory(const char *fname, int lineno, POOLMEM *obuf, int32_t size) { char *cp = (char *)obuf; void *buf; int pool; ASSERT(obuf); P(mutex); cp -= HEAD_SIZE; buf = sm_realloc(fname, lineno, cp, size+HEAD_SIZE); if (buf == NULL) { V(mutex); Emsg1(M_ABORT, 0, _("Out of memory requesting %d bytes\n"), size); } ((struct abufhead *)buf)->ablen = size; pool = ((struct abufhead *)buf)->pool; if (size > pool_ctl[pool].max_allocated) { pool_ctl[pool].max_allocated = size; } V(mutex); return (POOLMEM *)(((char *)buf)+HEAD_SIZE); }