fix (kernel): heap init takes now a heap pointer instead of creating a heap struct
This commit is contained in:
parent
cd8704eabc
commit
52d400d0c6
|
@ -35,7 +35,7 @@ typedef struct {
|
||||||
heap_segment_T* last_segment;
|
heap_segment_T* last_segment;
|
||||||
} heap_T;
|
} heap_T;
|
||||||
|
|
||||||
heap_T heap_create (void* base);
|
void heap_init (heap_T* heap, void* base);
|
||||||
void* heap_memory_allocate (heap_T* heap, uint64_t size);
|
void* heap_memory_allocate (heap_T* heap, uint64_t size);
|
||||||
void heap_memory_free (heap_T* heap, void* address);
|
void heap_memory_free (heap_T* heap, void* address);
|
||||||
void heap_dump_segments (heap_T* heap);
|
void heap_dump_segments (heap_T* heap);
|
||||||
|
|
|
@ -81,9 +81,7 @@ bool heap_segment_shrink(heap_T* heap, heap_segment_T* segment, uint64_t size) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
heap_T heap_create(void* base) {
|
void heap_init(heap_T* heap, void* base) {
|
||||||
heap_T heap;
|
|
||||||
|
|
||||||
uint64_t num_pages = 2;
|
uint64_t num_pages = 2;
|
||||||
uint64_t size = num_pages * PFRAME_SIZE;
|
uint64_t size = num_pages * PFRAME_SIZE;
|
||||||
|
|
||||||
|
@ -95,11 +93,9 @@ heap_T heap_create(void* base) {
|
||||||
|
|
||||||
heap_segment_init(base_segment, NULL, NULL, size - sizeof(heap_segment_T));
|
heap_segment_init(base_segment, NULL, NULL, size - sizeof(heap_segment_T));
|
||||||
|
|
||||||
heap.start = base;
|
heap->start = base;
|
||||||
heap.end = base + size;
|
heap->end = base + size;
|
||||||
heap.last_segment = base_segment;
|
heap->last_segment = base_segment;
|
||||||
|
|
||||||
return heap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
heap_segment_T* heap_append_segment(heap_T* heap, uint64_t minimum_size) {
|
heap_segment_T* heap_append_segment(heap_T* heap, uint64_t minimum_size) {
|
||||||
|
@ -190,6 +186,8 @@ void heap_dump_segments(heap_T* heap) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void heap_memory_free(heap_T* heap, void* address) {
|
void heap_memory_free(heap_T* heap, void* address) {
|
||||||
|
if (heap->start == NULL) { return; }
|
||||||
|
|
||||||
heap_segment_T* segment = (heap_segment_T*)(address - sizeof(heap_segment_T));
|
heap_segment_T* segment = (heap_segment_T*)(address - sizeof(heap_segment_T));
|
||||||
if (!heap_segment_validate(segment)) {
|
if (!heap_segment_validate(segment)) {
|
||||||
log(LOG_ERROR, "Heap Segment Invalid! while trying to free 0x%x", address);
|
log(LOG_ERROR, "Heap Segment Invalid! while trying to free 0x%x", address);
|
||||||
|
|
Loading…
Reference in New Issue