summaryrefslogtreecommitdiff
path: root/README
diff options
context:
space:
mode:
authorMatthew Sotoudeh <matthew@masot.net>2024-05-16 10:39:47 -0700
committerMatthew Sotoudeh <matthew@masot.net>2024-05-16 10:39:47 -0700
commit35674243f07216ce94c2680fde13ee9df48d766c (patch)
tree994a678e6385d750731afe2ca71e1911c21db797 /README
parenteb0bb6e38beff1517453502f78c1df994e4bb48c (diff)
support for moving the allocation pool
Diffstat (limited to 'README')
-rw-r--r--README22
1 files changed, 3 insertions, 19 deletions
diff --git a/README b/README
index debd59b..d85de3f 100644
--- a/README
+++ b/README
@@ -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
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback