123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #include <stdlib.h>
- #include "heap.h"
- void *
- __heap_alloc (struct heap_free_area **heap, size_t *size)
- {
- struct heap_free_area *fa;
- size_t _size = *size;
- void *mem = 0;
- _size = HEAP_ADJUST_SIZE (_size);
- if (_size < sizeof (struct heap_free_area))
-
- _size = HEAP_ADJUST_SIZE (sizeof (struct heap_free_area));
- HEAP_DEBUG (*heap, "before __heap_alloc");
-
- for (fa = *heap; fa; fa = fa->next)
- if (fa->size >= _size)
- {
-
- mem = HEAP_FREE_AREA_START (fa);
- *size = __heap_free_area_alloc (heap, fa, _size);
- break;
- }
- HEAP_DEBUG (*heap, "after __heap_alloc");
- return mem;
- }
|