Add example and readme

This commit is contained in:
2024-05-09 22:55:42 +02:00
parent 532eabb264
commit c6bfc90bcd
6 changed files with 82 additions and 6 deletions
+2 -2
View File
@@ -46,7 +46,7 @@ int main(void)
int i = rand() % num_current_allocs;
struct alloc_info deallocating = current_allocs[i];
current_allocs[i] = current_allocs[--num_current_allocs];
fprintf(stderr, "buddy_free(%lu, %lu)\n", deallocating.len, (uintptr_t) deallocating.ptr - (uintptr_t) alloc.base);
fprintf(stderr, "buddy_free(%d, %d)\n", (int) deallocating.len, (int) ((uintptr_t) deallocating.ptr - (uintptr_t) alloc.base));
buddy_free(&alloc, deallocating.len, (void*) deallocating.ptr);
}
}
@@ -61,7 +61,7 @@ int main(void)
//fprintf(stderr, "buddy_malloc(%lu) = NULL\n", len);
} else {
//buddy_dump(&alloc, stderr);
fprintf(stderr, "buddy_malloc(%lu) = %lu\n", len, (uintptr_t) ptr - (uintptr_t) alloc.base);
fprintf(stderr, "buddy_malloc(%d) = %d\n", (int) len, (int) ((uintptr_t) ptr - (uintptr_t) alloc.base));
}
if (ptr != NULL) {