blob: 6d31108c49fd6abb0b865edeac44d064f01445f5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
/*
* Advanced memory pool allocation scheme.
* $Id$
* Copyright (c) 1997 by Tycho Softworks.
* For conditions of distribution and reuse consult product license.
*/
#include <other/memory.h>
#include <std/math.h>
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);
}
|