realloc_check(Void_t* oldmem, size_t bytes, const Void_t *caller) #else
realloc_check(oldmem, bytes, caller)     Void_t* oldmem; size_t bytes; const Void_t *caller;#endif{  mchunkptr oldp;  INTERNAL_SIZE_T nb, oldsize;  Void_t* newmem = 0;  if (oldmem == 0) return malloc_check(bytes, NULL);  (void)mutex_lock(&main_arena.mutex);  oldp = mem2chunk_check(oldmem);  (void)mutex_unlock(&main_arena.mutex);  if(!oldp) {    if(check_action & 1)      fprintf(stderr, "realloc(): invalid pointer %p!\n", oldmem);    if(check_action & 2)      abort();    return malloc_check(bytes, NULL);  }  oldsize = chunksize(oldp);  checked_request2size(bytes+1, nb);  (void)mutex_lock(&main_arena.mutex);#if HAVE_MMAP  if (chunk_is_mmapped(oldp)) {#if HAVE_MREMAP    mchunkptr newp = mremap_chunk(oldp, nb);    if(!newp) {#endif      /* Note the extra SIZE_SZ overhead. */      if(oldsize - SIZE_SZ >= nb)	newmem = oldmem; /* do nothing */      else {        /* Must alloc, copy, free. */        if (top_check() >= 0)	  newmem = _int_malloc(&main_arena, bytes+1);        if (newmem) {          MALLOC_COPY(BOUNDED_N(newmem, bytes+1), oldmem, oldsize - 2*SIZE_SZ);          munmap_chunk(oldp);        }      }#if HAVE_MREMAP    }#endif  } else {#endif /* HAVE_MMAP */    if (top_check() >= 0)      newmem = _int_realloc(&main_arena, oldmem, bytes+1);#if 0 /* Erase freed memory. */    if(newmem)      newp = mem2chunk(newmem);    nb = chunksize(newp);    if(oldp<newp || oldp>=chunk_at_offset(newp, nb)) {      memset((char*)oldmem + 2*sizeof(mbinptr), 0,             oldsize - (2*sizeof(mbinptr)+2*SIZE_SZ+1));    } else if(nb > oldsize+SIZE_SZ) {      memset((char*)BOUNDED_N(chunk2mem(newp), bytes) + oldsize,	     0, nb - (oldsize+SIZE_SZ));    }#endif#if HAVE_MMAP  }#endif  (void)mutex_unlock(&main_arena.mutex);  return mem2mem_check(newmem, bytes);}