feat(ll): provide a ds_*ll_init func for consistency

This commit is contained in:
2025-09-05 18:41:03 -04:00
parent 1f7cba9338
commit 4248a678c1
2 changed files with 26 additions and 0 deletions

12
ds.c
View File

@@ -3,6 +3,18 @@
#include "ds.h"
ds_sll_t
*ds_sll_init(void)
{
return ds_sll_new_node(NULL);
}
ds_dll_t
*ds_dll_init(void)
{
return ds_dll_new_node(NULL);
}
ds_sll_t
*ds_sll_new_node(void *data)
{

14
ds.h
View File

@@ -24,6 +24,20 @@ typedef struct {
#define ds_ll_foreach(t, ll) for (t *cur = ll; cur; cur = cur->next)
/**
* @brief initialize a new singly linked list
*
* @return the new linked list
*/
ds_sll_t *ds_sll_init(void);
/**
* @brief initialize a new doubly linked list
*
* @return the new linked list
*/
ds_dll_t *ds_dll_init(void);
/**
* @brief create a new allocated node for a singly linked list
*