Fix and Free
Added the ability to free data from a zone. Also made some fixes to make sure that our numbers format properly in print statements.
This commit is contained in:
@@ -3,15 +3,15 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("Size of i16: %i\n", sizeof(i16));
|
||||
printf("Size of u16: %i\n", sizeof(u16));
|
||||
printf("Size of i32: %i\n", sizeof(i32));
|
||||
printf("Size of u32: %i\n", sizeof(u32));
|
||||
printf("Size of i64: %i\n", sizeof(i64));
|
||||
printf("Size of u64: %i\n", sizeof(u64));
|
||||
printf("Size of f32: %i\n", sizeof(f32));
|
||||
printf("Size of f64: %i\n", sizeof(f64));
|
||||
|
||||
printf("Size of i16: %" PRId16 "\n", sizeof(i16));
|
||||
printf("Size of u16: %" PRIu16 "\n", sizeof(u16));
|
||||
printf("Size of i32: %" PRId32 "\n", sizeof(i32));
|
||||
printf("Size of u32: %" PRIu32 "\n", sizeof(u32));
|
||||
printf("Size of i64: %" PRId64 "\n", sizeof(i64));
|
||||
printf("Size of u64: %" PRIu64 "\n", sizeof(u64));
|
||||
printf("Size of f32: %lu\n", sizeof(f32));
|
||||
printf("Size of f64: %lu\n", sizeof(f64));
|
||||
|
||||
printf("\nCreating new zone 4K in size...\n");
|
||||
Zone *test_zone = zoneCreate(4096);
|
||||
|
||||
@@ -20,11 +20,29 @@ int main() {
|
||||
|
||||
printf("Address of test_zone: %p\n", (void *)test_zone);
|
||||
printf("Address of test_alloc: %p\n", test_alloc);
|
||||
printf("Address of test_alloc2: %p\n", test_alloc2);
|
||||
printf("Address of test_alloc2: %p\n\n", test_alloc2);
|
||||
|
||||
zoneClear(test_zone);
|
||||
|
||||
u64 *test_free = zoneAlloc(test_zone, sizeof(u64));
|
||||
|
||||
printf("Address of test_free: %p\n", (void *)test_free);
|
||||
printf("Freeing test_free...\n");
|
||||
|
||||
zoneFree(&test_free, sizeof(u64));
|
||||
|
||||
printf("Is test_free NULL: %s\n\n", test_free == NULL ? "true" : "false");
|
||||
|
||||
zoneDestroy(test_zone);
|
||||
|
||||
const u64 FOUR_GIGS = (u64)4 * 1024 * 1024 * 1024;
|
||||
|
||||
Zone *break_zone = zoneCreate(FOUR_GIGS);
|
||||
|
||||
while (zoneAlloc(break_zone, 1024 * 1024 * 1024) != NULL) {
|
||||
}
|
||||
|
||||
zoneDestroy(break_zone);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user