add item access
This commit is contained in:
10
src/memory.c
10
src/memory.c
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user