fix bugs with inline linked list macros

This commit is contained in:
2025-02-10 12:39:08 -05:00
parent 632bc6d47f
commit 03ae07485b
2 changed files with 14 additions and 9 deletions
+9 -8
View File
@@ -391,7 +391,7 @@ dll__insert_npz(
void* n, void** n_prev, void** n_next
)
{
if (*f == nil) {
if (check_nil(nil, *f)) {
*f = n;
*l = n;
*n_prev = nil;
@@ -399,7 +399,7 @@ dll__insert_npz(
}
else
{
if (p == nil) {
if (check_nil(nil, p)) {
*n_next = *f;
*f_prev = n;
*f = n;
@@ -415,7 +415,7 @@ dll__insert_npz(
}
else
{
if ( ! (! (p == nil) && *p_next == nil)) {
if ( ! check_nil(nil, p) && check_nil(nil, *p_next)) {
*p_next_prev = n;
}
*n_next = *p_next;
@@ -494,10 +494,10 @@ dll__remove_npz(
if (n == *l) {
*l = l_prev;
}
if (n_prev != nil) {
if (check_nil(nil, n_prev)) {
*n_prev_next = n_next;
}
if (n_next != nil) {
if (! check_nil(nil, n_next)) {
*n_next_prev = n_prev;
}
}
@@ -546,14 +546,15 @@ sll__queue_push_nz(
void* n, void** n_next
)
{
if (*f == nil) {
if (check_nil(nil, *f)) {
*f = n;
*l = n;
*n_next = nil;
}
else {
*l_next = n;
*l = n;
n_next = nil;
*n_next = nil;
}
}
@@ -581,7 +582,7 @@ sll__queue_push_nz(
#ifndef sll_queue_push_front_nz
inline void
sll__queue_push_front_nz(void* nil, void** f, void** l, void* n, void** n_next) {
if (*f == nil) {
if (check_nil(nil, *f)) {
*f = n;
*l = n;
}
+5 -1
View File
@@ -1,6 +1,7 @@
// This is test strictly for the granular (non-generated) version of the library to make sure it operates correctly
// #define MD_DONT_MAP_ANREA_TO_ALLOCATOR_IMPL
// #define MD_LINKED_LIST_PURE_MACRO 1
// #define MD_DONT_MAP_ANREA_TO_ALLOCATOR_IMPL 1
#include "metadesk.c"
// This program expects to be run from the build directory (where it would be after being built)
@@ -21,5 +22,8 @@ int main()
Arena* arena = arena_alloc();
String8 hello_world_mdesk = os_data_from_file_path(arena, text(path_hello_world_mdesk));
TokenizeResult lexed = tokenize_from_text (arena, hello_world_mdesk);
ParseResult parsed = parse_from_text_tokens(arena, text(path_hello_world_mdesk), hello_world_mdesk, lexed.tokens);
deinit(& ctx);
}