diff options
| author | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2025-11-02 15:39:43 -0500 |
|---|---|---|
| committer | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2025-11-02 15:39:43 -0500 |
| commit | 04b57a756402e156953edfa2079d69b41db26e51 (patch) | |
| tree | 8bbfc5301c960a72b67918f37456460e23e496ba /include/free_list.h | |
| parent | 24d5cd8e806477b0fd2ddb5a232e672707f0da34 (diff) | |
| download | liballoc-04b57a756402e156953edfa2079d69b41db26e51.tar.gz | |
Updated free list interface
I realized my existing interface wouldn't work
if the coalescing or adding of a new node replaced
the head of the list, as there was no way to
communicate that back to the caller. As a result,
I've updated those interfaces to accept a pointer
to the free list head pointer. This will let them
change the free list head in alloc.c if necessary.
Diffstat (limited to 'include/free_list.h')
| -rw-r--r-- | include/free_list.h | 11 |
1 files changed, 9 insertions, 2 deletions
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 |