v1.1.3 - Align Arena_Region data flexible array member
This commit is contained in:
5
arena.h
5
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.
|
// single header library for region-based memory management.
|
||||||
//
|
//
|
||||||
// [License and changelog]
|
// [License and changelog]
|
||||||
@@ -158,7 +158,7 @@ struct Arena_Region {
|
|||||||
Arena_Region *next;
|
Arena_Region *next;
|
||||||
size_t count;
|
size_t count;
|
||||||
size_t capacity;
|
size_t capacity;
|
||||||
uint8_t data[];
|
alignas(ARENA_ALIGNMENT) uint8_t data[];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Arena {
|
typedef struct Arena {
|
||||||
@@ -335,6 +335,7 @@ char *arena_strdup(Arena *a, const char *s)
|
|||||||
/*
|
/*
|
||||||
* Revision history:
|
* 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.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.1 (2025-11-18) Implement memory alignment; improve docs
|
||||||
* 1.1.0 (2025-11-18) New helper functions: arena_copy(), arena_strdup()
|
* 1.1.0 (2025-11-18) New helper functions: arena_copy(), arena_strdup()
|
||||||
|
|||||||
8
test.c
8
test.c
@@ -25,7 +25,15 @@ void arena_print(Arena arena)
|
|||||||
|
|
||||||
int main(void)
|
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("Alignment: %zu\n", ARENA_ALIGNMENT);
|
||||||
|
printf("================================================================\n");
|
||||||
|
|
||||||
Arena a = {0};
|
Arena a = {0};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user