if (__after_morecore_hook) (*__after_morecore_hook) ();
main_trim(size_t pad)#elsemain_trim(pad) size_t pad;#endif{  mchunkptr top_chunk;   /* The current top chunk */  long  top_size;        /* Amount of top-most memory */  long  extra;           /* Amount to release */  char* current_brk;     /* address returned by pre-check sbrk call */  char* new_brk;         /* address returned by negative sbrk call */  unsigned long pagesz = malloc_getpagesize;  top_chunk = top(&main_arena);  top_size = chunksize(top_chunk);  extra = ((top_size - pad - MINSIZE + (pagesz-1)) / pagesz - 1) * pagesz;  if (extra < (long)pagesz) /* Not enough memory to release */    return 0;  /* Test to make sure no one else called sbrk */  current_brk = (char*)(MORECORE (0));  if (current_brk != (char*)(top_chunk) + top_size)    return 0;     /* Apparently we don't own memory; must fail */  new_brk = (char*)(MORECORE (-extra));  if (new_brk == (char*)(MORECORE_FAILURE)) { /* sbrk failed? */    /* Try to figure out what we have */    current_brk = (char*)(MORECORE (0));    top_size = current_brk - (char*)top_chunk;    if (top_size >= (long)MINSIZE) /* if not, we are very very dead! */    {      sbrked_mem = current_brk - sbrk_base;      set_head(top_chunk, top_size | PREV_INUSE);    }    check_chunk(&main_arena, top_chunk);    return 0;  }  sbrked_mem -= extra;  /* Success. Adjust top accordingly. */  set_head(top_chunk, (top_size - extra) | PREV_INUSE);  check_chunk(&main_arena, top_chunk);  return 1;}