Browse Source

Started work on types and prototypes

Thomas Johnson 1 year ago
parent
commit
7719e8f36c
1 changed files with 49 additions and 0 deletions
  1. 49
    0
      allocator_internal.h

+ 49
- 0
allocator_internal.h View File

@@ -0,0 +1,49 @@
1
+#ifndef ALLOCATOR_INTERNAL_H
2
+#define ALLOCATOR_INTERNAL_H
3
+
4
+#include <stdint.h>
5
+#include <sys/types.h>
6
+
7
+// No enum because these need to be 1 byte
8
+const char RT_FREESPACE = 0;
9
+const char RT_TREE_NODE = 1;
10
+const char RT_WATERMARK = 2;
11
+
12
+struct TopLevel {
13
+  struct FreeSpace *root_freespace;
14
+  struct TreeAlloc *root_treealloc;
15
+}
16
+
17
+// All three of these types should be memory-compatible with each other
18
+
19
+struct TreeAlloc {
20
+  char type;  // Should be RT_TREE_NODE
21
+  struct TreeAlloc *parent;
22
+  struct TreeAlloc *left;
23
+  struct TreeAlloc *right;
24
+  size_t size;
25
+}
26
+
27
+struct FreeSpace {
28
+  char type;  // Should be RT_FREESPACE
29
+  struct FreeSpace *parent;
30
+  struct FreeSpace *left;
31
+  struct FreeSpace *right;
32
+  size_t size;
33
+}
34
+
35
+struct WatermarkAlloc {
36
+  char type;  // Should be RT_WATERMARK
37
+  struct TreeAlloc *parent;
38
+  struct TreeAlloc *left;
39
+  struct TreeAlloc *right;
40
+  size_t size;
41
+  int num_allocs;
42
+  void *next_alloc;
43
+}
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);
48
+
49
+#endif

Loading…
Cancel
Save