summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorMatthew Sotoudeh <matthew@masot.net>2024-05-16 10:08:06 -0700
committerMatthew Sotoudeh <matthew@masot.net>2024-05-16 10:08:06 -0700
commiteb0bb6e38beff1517453502f78c1df994e4bb48c (patch)
tree35c3e1e8333c06a34bb50d8ba9c1f70b03712fda /main.c
parent06612e93bd5c115ae878c198594c4855edabd331 (diff)
no globals
Diffstat (limited to 'main.c')
-rw-r--r--main.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/main.c b/main.c
index e3b62bd..a288f1c 100644
--- a/main.c
+++ b/main.c
@@ -13,18 +13,20 @@ void get_random(uint8_t *dst, size_t count) {
}
void main() {
+ struct buddy buddy;
+
size_t region_size = 1024 * 1024;
uint8_t magic[MAGIC_COOKIE_BYTES];
get_random(magic, MAGIC_COOKIE_BYTES);
- init_buddy(malloc(region_size), region_size, magic);
+ init_buddy(malloc(region_size), region_size, magic, &buddy);
memset(magic, 0, sizeof(magic));
- void *x = allocate(1024);
+ void *x = allocate(1024, &buddy);
printf("Just allocated %p...\n", x);
- debug_buddy();
+ debug_buddy(&buddy);
printf("Now liberating %p...\n", x);
- liberate(x, 1024);
- debug_buddy();
+ liberate(x, 1024, &buddy);
+ debug_buddy(&buddy);
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback