Skip to content

Commit 9037570

Browse files
author
di
committed
[MEM] alloc header fixes
1 parent e105375 commit 9037570

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

kernel/memory/memory_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include "types.h"
44

5+
//DEADLINE: 01/03/2026 - will merge with alloc/mem_types.h
6+
57
typedef struct FreeBlock {
68
uint64_t size;
79
struct FreeBlock* next;

kernel/memory/mmu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "process/scheduler.h"
1313
#include "sysregs.h"
1414
#include "std/memory.h"
15+
#include "alloc/mem_types.h"
1516

1617
#define PD_TABLE 0b11
1718
#define PD_BLOCK 0b01

kernel/memory/page_allocator.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
#pragma once
22

33
#include "types.h"
4-
#include "memory_types.h"
5-
6-
#define ALIGN_4KB 0x1000
7-
#define ALIGN_16B 0x10
8-
#define ALIGN_64B 0x40
9-
#define PAGE_SIZE 4096
4+
#include "alloc/mem_types.h"
105

116
#define MEM_PRIV_USER 0
127
#define MEM_PRIV_KERNEL 1
@@ -31,6 +26,7 @@ void mark_used(uintptr_t address, size_t pages);
3126

3227
bool page_used(uintptr_t ptr);
3328

29+
//DEADLINE: 13/02/2026 - will be merged with alloc/allocate
3430
void* kalloc_inner(void *page, size_t size, uint16_t alignment, uint8_t level, uintptr_t page_va, uintptr_t *next_va, uintptr_t *ttbr);
3531
void* kalloc(void *page, size_t size, uint16_t alignment, uint8_t level);
3632
void kfree(void* ptr, size_t size);

utils/terminal/terminal.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "terminal.hpp"
2+
#include "alloc/allocate.h"
23
#include "std/std.h"
34
#include "input_keycodes.h"
45

@@ -174,7 +175,7 @@ bool Terminal::exec_cmd(const char *cmd, int argc, const char *argv[]){
174175

175176
int state = 1;
176177
size_t amount = 0x100;
177-
char *buf = (char*)malloc(amount + 1);
178+
char *buf = (char*)zalloc(amount + 1);
178179
if (!buf) {
179180
closef(&out_fd);
180181
closef(&state_fd);
@@ -208,7 +209,7 @@ bool Terminal::exec_cmd(const char *cmd, int argc, const char *argv[]){
208209

209210
const char** Terminal::parse_arguments(char *args, int *count){
210211
*count = 0;
211-
const char **argv = (const char**)malloc(16 * sizeof(uintptr_t));
212+
const char **argv = (const char**)zalloc(16 * sizeof(uintptr_t));
212213
char* p = args;
213214

214215
while (*p && *count < 16){
@@ -280,11 +281,11 @@ void Terminal::run_command(){
280281
} else {
281282
string s = string_format("Unknown command %s", cmd.data);
282283
put_string(s.data);
283-
free_sized(s.data, s.mem_length);
284+
string_free(s);
284285
}
285286
}
286287

287-
if (argv) free_sized((void*)argv, 16 * sizeof(uintptr_t));
288+
if (argv) release((void*)argv);
288289
free_sized(cmd.data, cmd.mem_length);
289290
if (args_copy.mem_length) free_sized(args_copy.data, args_copy.mem_length);
290291

0 commit comments

Comments
 (0)