memory: use libc malloc/free in testing

This commit is contained in:
Edgaru089 2021-11-07 01:24:40 +08:00
parent 4460661bfd
commit 763c34c8de

View File

@ -52,12 +52,28 @@ void *efiMalloc(size_t size);
void efiFree(void *data);
#ifdef HELOS
// kMalloc allocates from system memory directly after paging has been set up
void *kMalloc(size_t size);
// kFree frees data allocated from kMalloc.
void kFree(void *data);
#else
// use stdc malloc/free in testing
#include <malloc.h>
#include <stdio.h>
static inline void *kMalloc(size_t size) {
void *mem = malloc(size);
printf("kMalloc: size=%llu, pos=0x%llx\n", size, mem);
return mem;
}
static inline void kFree(void *data) {
printf("kFree: 0x%llx\n", data);
free(data);
}
#endif
// runtime_InitPaging initializes paging and kMalloc/kFree allocator.
// This function calls ExitBootServices()!!! which is great