summaryrefslogtreecommitdiffstats
path: root/tests/alloc.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-06-19 16:58:24 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-06-20 14:26:09 -0400
commitcbe2c473c9aee71f5f770dc7f41973d2ef4c273c (patch)
tree20ac0bcc4b9f86684b737dde2bb8f19b90634f3b /tests/alloc.c
parenteb83f2a91a615c5fa3788d41c3ec80b43bf5ed28 (diff)
downloadbfs-cbe2c473c9aee71f5f770dc7f41973d2ef4c273c.tar.xz
alloc: Implement an arena for flexible structs
Diffstat (limited to 'tests/alloc.c')
-rw-r--r--tests/alloc.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/alloc.c b/tests/alloc.c
index 91b1b43..9e6e892 100644
--- a/tests/alloc.c
+++ b/tests/alloc.c
@@ -8,7 +8,7 @@
int main(void) {
// Check sizeof_flex()
struct flexible {
- alignas(64) int foo;
+ alignas(64) int foo[8];
int bar[];
};
bfs_verify(sizeof_flex(struct flexible, bar, 0) >= sizeof(struct flexible));
@@ -20,5 +20,17 @@ int main(void) {
// Doesn't happen in typical ABIs
bfs_verify(flex_size(8, 16, 4, 4, 1) == 16);
+ // varena tests
+ struct varena varena;
+ VARENA_INIT(&varena, struct flexible, bar);
+
+ for (size_t i = 0; i < 256; ++i) {
+ bfs_verify(varena_alloc(&varena, i));
+ struct arena *arena = &varena.arenas[varena.narenas - 1];
+ bfs_verify(arena->size >= sizeof_flex(struct flexible, bar, i));
+ }
+
+ varena_destroy(&varena);
+
return EXIT_SUCCESS;
}