some correctness changes

This commit is contained in:
2026-01-13 22:40:55 -05:00
parent f75c8141d4
commit f13a774766

View File

@@ -1,9 +1,11 @@
#include <stdlib.h>
#include <stdbool.h>
#ifndef __NICKEL_LINKEDLIST_H_
#define __NICKEL_LINKEDLIST_H_
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
typedef struct ni_list_node {
struct ni_list_node* next;
struct ni_list_node* prev;
@@ -46,10 +48,10 @@ static inline ni_list_node* ni_list__get_back(ni_list* l) {
/* Iter Helpers */
#define NI_LIST__FOREACH(lptr) \
for (ni_list_node* it = ni_list__get_front(lptr); it != &(lptr)->head; it = it->next)
for (ni_list_node* it = (lptr)->head.next; it != &(lptr)->head; it = it->next)
#define NI_LIST_FOREACH_SAFE(tmp, lptr) \
for (ni_list_node* it = ni_list__get_front(lptr), *tmp = it->next; \
for (ni_list_node* it = (lptr)->head.next, *tmp = it->next; \
it != &(lptr)->head; \
it = tmp, tmp = it-> next)