void afree(void *ptr, Area *ap) { struct link *l, *l2; if (!ptr) return; l = P2L(ptr); for (l2 = ap->freelist; l2 != NULL; l2 = l2->next) { if (l == l2) break; } if (l2 == NULL) internal_errorf(1, "afree: %p not present in area %p", ptr, ap); if (l->prev) l->prev->next = l->next; else ap->freelist = l->next; if (l->next) l->next->prev = l->prev; free(l); }
void afree(void *ptr, Area *ap) { struct link *l; if (!ptr) return; l = P2L(ptr); if (l->prev) l->prev->next = l->next; else ap->freelist = l->next; if (l->next) l->next->prev = l->prev; free(l); }
void * aresize(void *ptr, size_t size, Area *ap) { struct link *l, *l2, *lprev, *lnext; if (ptr == NULL) return alloc(size, ap); l = P2L(ptr); lprev = l->prev; lnext = l->next; l2 = realloc(l, sizeof(struct link) + size); if (l2 == NULL) internal_errorf(1, "unable to allocate memory"); if (lprev) lprev->next = l2; else ap->freelist = l2; if (lnext) lnext->prev = l2; return L2P(l2); }