mirror of
https://codeberg.org/andyscott/marCsweep.git
synced 2024-12-22 17:53:10 -05:00
27 lines
618 B
C
27 lines
618 B
C
|
#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 */
|