diff --git a/arena.h b/arena.h index ec9ae52..a9f45ef 100644 --- a/arena.h +++ b/arena.h @@ -1,4 +1,4 @@ -// arena.h - v1.1.2 - MIT License +// arena.h - v1.1.3 - MIT License // single header library for region-based memory management. // // [License and changelog] @@ -158,7 +158,7 @@ struct Arena_Region { Arena_Region *next; size_t count; size_t capacity; - uint8_t data[]; + alignas(ARENA_ALIGNMENT) uint8_t data[]; }; typedef struct Arena { @@ -335,6 +335,7 @@ char *arena_strdup(Arena *a, const char *s) /* * Revision history: * + * 1.1.3 (2026-01-14) Align Arena_Region data flexible array member * 1.1.2 (2026-01-10) Minor changes; check result of alloc in arena_copy() * 1.1.1 (2025-11-18) Implement memory alignment; improve docs * 1.1.0 (2025-11-18) New helper functions: arena_copy(), arena_strdup() diff --git a/test.c b/test.c index 9bef270..15bc8ab 100644 --- a/test.c +++ b/test.c @@ -25,7 +25,15 @@ void arena_print(Arena arena) int main(void) { + printf("struct Arena_Region {\n"); + printf(" Arena_Region *next; (%zu)\n", offsetof(struct Arena_Region, next)); + printf(" size_t count; (%zu)\n", offsetof(struct Arena_Region, count)); + printf(" size_t capacity; (%zu)\n", offsetof(struct Arena_Region, capacity)); + printf(" uint8_t data[]; (%zu)\n", offsetof(struct Arena_Region, data)); + printf("};\n"); + printf("Alignment: %zu\n", ARENA_ALIGNMENT); + printf("================================================================\n"); Arena a = {0};