Browse Source

Some minor tweaks that will help down the line

Cameron Weinfurt 1 year ago
parent
commit
668699ea89
2 changed files with 14 additions and 13 deletions
  1. 5
    4
      Makefile
  2. 9
    9
      allocator_internal.h

+ 5
- 4
Makefile View File

@@ -1,21 +1,22 @@
1 1
 objs = main.o
2 2
 
3 3
 CC = clang
4
+COMMON_FLAGS = -std=c11
4 5
 OUT_NAME = the_alloc
5 6
 
6
-dev: FLAGS= -g -D UNIT_TESTS
7
+dev: CFLAGS= $(COMMON_FLAGS) -g -D UNIT_TESTS
7 8
 dev: $(OUT_NAME)
8 9
 	valgrind ./$(OUT_NAME)
9 10
 
10
-release: FLAGS= -O2
11
+release: CFLAGS= $(COMMON_FLAGS) -O2
11 12
 release: clean $(OUT_NAME)
12 13
 	rm *.o
13 14
 
14 15
 $(OUT_NAME): $(objs)
15
-	$(CC) $(FLAGS) -o $(OUT_NAME) $(objs)
16
+	$(CC) $(CFLAGS) -o $(OUT_NAME) $(objs)
16 17
 
17 18
 clean:
18 19
 	rm -f *.o $(OUT_NAME)
19 20
 
20 21
 main.o: main.c
21
-	$(CC) $(FLAGS) -c main.c -o main.o
22
+	$(CC) $(CFLAGS) -c main.c -o main.o

+ 9
- 9
allocator_internal.h View File

@@ -16,23 +16,23 @@ struct TopLevel {
16 16
 
17 17
 // All three of these types should be memory-compatible with each other
18 18
 
19
-struct TreeAlloc {
19
+typedef struct TreeAlloc {
20 20
   char type;  // Should be RT_TREE_NODE
21 21
   struct TreeAlloc *parent;
22 22
   struct TreeAlloc *left;
23 23
   struct TreeAlloc *right;
24 24
   size_t size;
25
-}
25
+} TreeAlloc
26 26
 
27
-struct FreeSpace {
27
+typedef struct FreeSpace {
28 28
   char type;  // Should be RT_FREESPACE
29 29
   struct FreeSpace *parent;
30 30
   struct FreeSpace *left;
31 31
   struct FreeSpace *right;
32 32
   size_t size;
33
-}
33
+} FreeSpace
34 34
 
35
-struct WatermarkAlloc {
35
+typedef struct WatermarkAlloc {
36 36
   char type;  // Should be RT_WATERMARK
37 37
   struct TreeAlloc *parent;
38 38
   struct TreeAlloc *left;
@@ -40,10 +40,10 @@ struct WatermarkAlloc {
40 40
   size_t size;
41 41
   int num_allocs;
42 42
   void *next_alloc;
43
-}
43
+} WatermarkAlloc
44 44
 
45
-struct TreeAlloc *insert_node_at(void *address, int padding, int align, int size);
46
-struct TreeAlloc *search_by_address(TreeAlloc *root, void *address);
47
-struct TreeAlloc *search_by_size(TreeAlloc *root, int padding, int align, int size);
45
+TreeAlloc *insert_node_at(void *address, int padding, int align, int size);
46
+TreeAlloc *search_by_address(TreeAlloc *root, void *address);
47
+TreeAlloc *search_by_size(TreeAlloc *root, int padding, int align, int size);
48 48
 
49 49
 #endif

Loading…
Cancel
Save