/* * Advanced memory pool allocation scheme. * $Id$ * Copyright (c) 1997 by Tycho Softworks. * For conditions of distribution and reuse consult product license. */ #include #include void *memalloc(MEMPOOL *mem, int len) { _MEMFREE *free = mem->mem_free; _MEMCELL *cell = NULL; len = align(len, __OBJALIGN); while(free) { if(free->size == len) { cell = free->list; break; } free = free->next; } if(cell) { free->list = cell->next; return cell; } return memreq(mem, len); }