Support C++ malloc pointer cast

This commit is contained in:
seajee
2025-07-24 13:03:02 +02:00
parent 5d487e1bce
commit 49e0e14d7c

View File

@@ -41,7 +41,7 @@ void *arena_alloc(Arena *a, size_t bytes)
// Empty arena // Empty arena
if (a->head == NULL) { if (a->head == NULL) {
size_t size = (bytes > ARENA_MIN_CAPACITY ? bytes : ARENA_MIN_CAPACITY); size_t size = (bytes > ARENA_MIN_CAPACITY ? bytes : ARENA_MIN_CAPACITY);
a->head = malloc(sizeof(*a->head) + size); a->head = (Arena_Region*)malloc(sizeof(*a->head) + size);
if (a->head == NULL) { if (a->head == NULL) {
return NULL; return NULL;
} }
@@ -66,7 +66,7 @@ void *arena_alloc(Arena *a, size_t bytes)
} }
// If not create a new region // If not create a new region
a->tail->next = malloc(sizeof(*a->tail) + bytes); a->tail->next = (Arena_Region*)malloc(sizeof(*a->tail) + bytes);
if (a->tail->next == NULL) { if (a->tail->next == NULL) {
return NULL; return NULL;
} }