marCsweep/include/gc_alloc.h

26 lines
624 B
C

#ifndef GC_ALLOC_H
#define GC_ALLOC_H
#include <stdio.h>
// Metadata for allocated memory - Headers are stored in a linked list to keep
// track of alloc's and free's
struct gcHeader {
size_t size;
int free;
struct gcHeader *next;
};
// Iterates over the galloc linked list attempting to find free space
struct gcHeader *findFree(struct gcHeader **prev, size_t size);
// Requests more memory from the kernel
struct gcHeader *requestMem(struct gcHeader *prev, size_t size);
// Performs allocations
void *galloc(size_t size);
// Frees memory allocated with galloc()
void gfree(void *ptr);
#endif /* GC_ALLOC_H */