/* * SPDX-FileCopyrightText: 2025 William Bell * * SPDX-License-Identifier: GPL-3.0-or-later */ #include "memory.h" #include #include #include #include #include // for malloc/free (temp arena fallback) #include void *checked_malloc(size_t size) { void *ptr = malloc(size); if (!ptr) { fprintf(stderr, "fatal error: failed to allocate %zu bytes\n", size); exit(EXIT_FAILURE); } return ptr; } void *checked_realloc(void *ptr, size_t size) { void *new_ptr = realloc(ptr, size); if (!new_ptr) { fprintf(stderr, "fatal error: failed to allocate %zu bytes\n", size); exit(EXIT_FAILURE); } return new_ptr; } struct allocation *memory_allocations = NULL; size_t memory_allocations_size = 0; pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; void ar_memory_init() { GC_INIT(); // memory_allocations_size = 8; // memory_allocations = malloc(memory_allocations_size*sizeof(struct // allocation)); } void ar_memory_shutdown() { // for (size_t i = 0; i