From 778a4da09264821a3716c72b0be235b6455f6a54 Mon Sep 17 00:00:00 2001 From: Abdelrahman Said Date: Wed, 16 Apr 2025 00:27:01 +0100 Subject: [PATCH] Add utility to create list node from item --- src/containers/dbl_list/dbl_list.h | 2 ++ src/core/strings/str8/str8.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/containers/dbl_list/dbl_list.h b/src/containers/dbl_list/dbl_list.h index 87b2620..b06c675 100644 --- a/src/containers/dbl_list/dbl_list.h +++ b/src/containers/dbl_list/dbl_list.h @@ -32,6 +32,8 @@ BEGIN_C_LINKAGE DBL_LIST_DECL(void); +#define wapp_dbl_list_node_from_item(T, ITEM_PTR) ((DBL_NODE(T)){ .item = ITEM_PTR }) + #define wapp_dbl_list_get(T, LIST_PTR, INDEX) \ (DBL_NODE(T)*)_dbl_list_get(CAST_LIST_PTR(LIST_PTR), INDEX) diff --git a/src/core/strings/str8/str8.h b/src/core/strings/str8/str8.h index 7b89132..7626bf1 100644 --- a/src/core/strings/str8/str8.h +++ b/src/core/strings/str8/str8.h @@ -92,8 +92,8 @@ Str8 *wapp_str8_join(const Allocator *allocator, const DBL_LIST(Str8) /** * Str8 list utilities */ -#define wapp_str8_node_from_cstr(STRING) ((DBL_NODE(Str8)){.item = &wapp_str8_lit(STRING)}) -#define wapp_str8_node_from_str8(STRING) ((DBL_NODE(Str8)){.item = &(STRING)}) +#define wapp_str8_node_from_cstr(STRING) wapp_dbl_list_node_from_item(Str8, &wapp_str8_lit(STRING)) +#define wapp_str8_node_from_str8(STRING) wapp_dbl_list_node_from_item(Str8, &(STRING)) #ifdef __cplusplus END_C_LINKAGE