Bladeren bron

Some minor tweaks that will help down the line

watermark_alloc
Cameron Weinfurt 1 jaar geleden
bovenliggende
commit
668699ea89
  1. 9
      Makefile
  2. 18
      allocator_internal.h

9
Makefile

@ -1,21 +1,22 @@
objs = main.o
CC = clang
COMMON_FLAGS = -std=c11
OUT_NAME = the_alloc
dev: FLAGS= -g -D UNIT_TESTS
dev: CFLAGS= $(COMMON_FLAGS) -g -D UNIT_TESTS
dev: $(OUT_NAME)
valgrind ./$(OUT_NAME)
release: FLAGS= -O2
release: CFLAGS= $(COMMON_FLAGS) -O2
release: clean $(OUT_NAME)
rm *.o
$(OUT_NAME): $(objs)
$(CC) $(FLAGS) -o $(OUT_NAME) $(objs)
$(CC) $(CFLAGS) -o $(OUT_NAME) $(objs)
clean:
rm -f *.o $(OUT_NAME)
main.o: main.c
$(CC) $(FLAGS) -c main.c -o main.o
$(CC) $(CFLAGS) -c main.c -o main.o

18
allocator_internal.h

@ -16,23 +16,23 @@ struct TopLevel {
// All three of these types should be memory-compatible with each other
struct TreeAlloc {
typedef struct TreeAlloc {
char type; // Should be RT_TREE_NODE
struct TreeAlloc *parent;
struct TreeAlloc *left;
struct TreeAlloc *right;
size_t size;
}
} TreeAlloc
struct FreeSpace {
typedef struct FreeSpace {
char type; // Should be RT_FREESPACE
struct FreeSpace *parent;
struct FreeSpace *left;
struct FreeSpace *right;
size_t size;
}
} FreeSpace
struct WatermarkAlloc {
typedef struct WatermarkAlloc {
char type; // Should be RT_WATERMARK
struct TreeAlloc *parent;
struct TreeAlloc *left;
@ -40,10 +40,10 @@ struct WatermarkAlloc {
size_t size;
int num_allocs;
void *next_alloc;
}
} WatermarkAlloc
struct TreeAlloc *insert_node_at(void *address, int padding, int align, int size);
struct TreeAlloc *search_by_address(TreeAlloc *root, void *address);
struct TreeAlloc *search_by_size(TreeAlloc *root, int padding, int align, int size);
TreeAlloc *insert_node_at(void *address, int padding, int align, int size);
TreeAlloc *search_by_address(TreeAlloc *root, void *address);
TreeAlloc *search_by_size(TreeAlloc *root, int padding, int align, int size);
#endif
Laden…
Annuleren
Opslaan