add item access

This commit is contained in:
2025-11-26 03:07:06 +00:00
parent 94b86fc416
commit f3912ae49f
22 changed files with 383 additions and 119 deletions

View File

@@ -6,7 +6,6 @@
#include "memory.h"
#include <gc.h>
#include <gc/gc.h>
#include <pthread.h>
#include <stddef.h>
#include <stdio.h>
@@ -22,6 +21,15 @@ void *checked_malloc(size_t size) {
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;