diff options
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 |