diff options
author | Matthew Sotoudeh <matthew@masot.net> | 2024-05-16 10:39:47 -0700 |
---|---|---|
committer | Matthew Sotoudeh <matthew@masot.net> | 2024-05-16 10:39:47 -0700 |
commit | 35674243f07216ce94c2680fde13ee9df48d766c (patch) | |
tree | 994a678e6385d750731afe2ca71e1911c21db797 /README | |
parent | eb0bb6e38beff1517453502f78c1df994e4bb48c (diff) |
support for moving the allocation pool
Diffstat (limited to 'README')
-rw-r--r-- | README | 22 |
1 files changed, 3 insertions, 19 deletions
@@ -54,27 +54,11 @@ in the computer's address size. ### Usage +Usage example in main.c. + First, initialize the library by giving it both the base + size for the allocation pool to be managed, along with some "very random" (or otherwise -secret) data. The following should work: - - // First, get some secret random data. - uint8_t secret[MAGIC_COOKIE_BYTES]; - int fd = open("/dev/urandom", O_RDONLY); - assert(count == read(fd, secret, count)); - close(fd); - - // Then initialize the buddy allocator. - init_buddy(malloc(1026 * 1024), 1024 * 1024, secret); - -Now, you can allocate and liberate as normal: - - // Get a region of 128 bytes - uint8_t *x = allocate(128); - // Write into it - x[123] = 1234; - // Liberate it - liberate(x, 128); +secret) data. Then, you can allocate and liberate as normal. ### License |