[refactor] Organize STRING

This commit is contained in:
2026-06-05 18:38:45 +08:00
Unverified
parent da03b301fb
commit 9ee88ef7b9
19 changed files with 124 additions and 51 deletions
+3 -9
View File
@@ -1,6 +1,7 @@
#include <memory/heap.h>
#include <memory/pmm.h>
#include <serial.h>
#include <string_utils.h>
struct heap_block {
UINTN size; // includes header; bit 0 = 1 used, 0 free
@@ -184,10 +185,7 @@ void* kcalloc(UINTN num, UINTN size) {
UINTN total = num * size;
void* ptr = kmalloc(total);
if (ptr) {
UINT8* p = (UINT8*)ptr;
for (UINTN i = 0; i < total; i++) {
p[i] = 0;
}
mem_set(ptr, 0, total);
}
return ptr;
}
@@ -216,11 +214,7 @@ void* krealloc(void* ptr, UINTN new_size) {
void* new_ptr = kmalloc(new_size);
if (new_ptr) {
UINT8* src = (UINT8*)ptr;
UINT8* dst = (UINT8*)new_ptr;
for (UINTN i = 0; i < old_size; i++) {
dst[i] = src[i];
}
mem_copy(new_ptr, ptr, old_size);
kfree(ptr);
}
return new_ptr;
+2
View File
@@ -1,5 +1,7 @@
#include <memory/pmm.h>
#include <common.h>
#include <serial.h>
#include <string_utils.h>
extern EFI_SYSTEM_TABLE *ST;