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