aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/alloc_header.h27
-rw-r--r--include/free_list.h11
2 files changed, 36 insertions, 2 deletions
diff --git a/include/alloc_header.h b/include/alloc_header.h
new file mode 100644
index 0000000..bf4716c
--- /dev/null
+++ b/include/alloc_header.h
@@ -0,0 +1,27 @@
+/*
+ * include/alloc_header.h
+ *
+ * liballoc memory block header type.
+ * CISC 301 -- Operating Systems, Project 3
+ *
+ * Copyright (C) 2025 Douglas B. Rumbaugh <dbrumbaugh@harrisburgu.edu>
+ *
+ * Distributed under the Modified BSD License
+ *
+ */
+#ifndef H_LIBALLOC_HEADER
+#define H_LIBALLOC_HEADER
+
+#include <stdlib.h>
+#include <assert.h>
+
+#include "constants.h"
+
+typedef struct header {
+ size_t size;
+ size_t magic_number;
+} header;
+
+static_assert(sizeof(header) % ALIGNMENT == 0, "Header improperly aligned");
+
+#endif
diff --git a/include/free_list.h b/include/free_list.h
index 887167b..1993aa7 100644
--- a/include/free_list.h
+++ b/include/free_list.h
@@ -15,6 +15,7 @@
#include <stdlib.h>
#include "constants.h"
+#include "alloc_header.h"
typedef struct free_nd {
size_t size;
@@ -34,9 +35,12 @@ free_nd *fl_find_first_fit(free_nd *free_list, size_t size);
* specified node cannot be split (e.g., it's an exact match for size
* within alignment restrictions), simply remove it from the list.
*
+ * If the head of the free list is updated by this operation, the free
+ * list pointer passed as an argument will be updated to reflect this
+ *
* Returns a pointer to the region of memory removed from the list.
*/
-void *fl_split_node(free_nd *free_list, free_nd *nd, size_t size);
+void *fl_split_node(free_nd **free_list, free_nd *nd, size_t size);
/*
* Scans the free list for adjacent nodes and merges them together
@@ -46,7 +50,10 @@ void fl_coalesce_nodes(free_nd *free_list);
/*
* Scans the free list for the correct location for the specified
* pointer, and link it into the list at that point.
+ *
+ * If the head of the free list is updated by this operation, the free
+ * list pointer passed as an argument will be updated to reflect this
*/
-void fl_add_node(free_nd *free_list, void *ptr);
+void fl_add_node(free_nd **free_list, void *ptr);
#endif