Skip to content

Commit 3fc8df1

Browse files
Implemented extending of heap.
1 parent 264a6f7 commit 3fc8df1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

source/includes/heap.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ typedef struct {
2121

2222
#define MAX_PAGE_ALIGNED_ALLOCS 32
2323

24-
extern void mm_init();
24+
extern void mm_init(uint32_t kernel_end);
25+
extern void mm_extend(uint32_t additional_size);
26+
2527
extern void mm_print_out();
2628

2729
extern char* pmalloc(size_t size);

source/kernel/C/heap.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ void mm_init(uint32_t kernel_end)
3232
pheap_desc = (uint8_t *)malloc(MAX_PAGE_ALIGNED_ALLOCS);
3333
}
3434

35+
void mm_extend(uint32_t additional_size)
36+
{
37+
if (additional_size <= 0) return;
38+
39+
heap_end += additional_size;
40+
printf("Heap extended by %d bytes. New heap end: 0x%x", additional_size, heap_end);
41+
}
42+
3543
void mm_print_out()
3644
{
3745
printf("%sMemory used :%s %d bytes", yellow_color, reset_color, memory_used);

0 commit comments

Comments
 (0)