summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorMatthew Sotoudeh <matthew@masot.net>2024-05-16 02:23:46 -0700
committerMatthew Sotoudeh <matthew@masot.net>2024-05-16 02:23:46 -0700
commited1ed2fc98cc795acd9bdc76be6d1df138c505c7 (patch)
treea815094c8577705b6bb71c8a23fd8fc2c5cdf0b7 /main.c
parentaffa5e2933186970d0a3dac38d2ca8f02190e4d9 (diff)
no longer require aligned base address
Diffstat (limited to 'main.c')
-rw-r--r--main.c11
1 files changed, 1 insertions, 10 deletions
diff --git a/main.c b/main.c
index b84e958..e3b62bd 100644
--- a/main.c
+++ b/main.c
@@ -12,21 +12,12 @@ void get_random(uint8_t *dst, size_t count) {
close(fd);
}
-// helper for getting an aligned allocation
-static void *malloc_aligned(size_t size) {
- uint8_t *data = malloc(size);
- if (!((size_t)data % size)) return data;
- data = realloc(data, size * 2);
- data = data + (size - ((size_t)data % size));
- return data;
-}
-
void main() {
size_t region_size = 1024 * 1024;
uint8_t magic[MAGIC_COOKIE_BYTES];
get_random(magic, MAGIC_COOKIE_BYTES);
- init_buddy(malloc_aligned(region_size), region_size, magic);
+ init_buddy(malloc(region_size), region_size, magic);
memset(magic, 0, sizeof(magic));
void *x = allocate(1024);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback