diff options
author | Matthew Sotoudeh <matthew@masot.net> | 2024-05-16 02:23:46 -0700 |
---|---|---|
committer | Matthew Sotoudeh <matthew@masot.net> | 2024-05-16 02:23:46 -0700 |
commit | ed1ed2fc98cc795acd9bdc76be6d1df138c505c7 (patch) | |
tree | a815094c8577705b6bb71c8a23fd8fc2c5cdf0b7 /main.c | |
parent | affa5e2933186970d0a3dac38d2ca8f02190e4d9 (diff) |
no longer require aligned base address
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 11 |
1 files changed, 1 insertions, 10 deletions
@@ -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); |