marCsweep/gc_alloc.h

27 lines
618 B
C
Raw Normal View History

#ifndef GALLOC_H
#define GALLOC_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 /* GALLOC_H */