some correctness changes
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
#include <stdlib.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#ifndef __NICKEL_LINKEDLIST_H_
|
#ifndef __NICKEL_LINKEDLIST_H_
|
||||||
#define __NICKEL_LINKEDLIST_H_
|
#define __NICKEL_LINKEDLIST_H_
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
typedef struct ni_list_node {
|
typedef struct ni_list_node {
|
||||||
struct ni_list_node* next;
|
struct ni_list_node* next;
|
||||||
struct ni_list_node* prev;
|
struct ni_list_node* prev;
|
||||||
@@ -46,10 +48,10 @@ static inline ni_list_node* ni_list__get_back(ni_list* l) {
|
|||||||
/* Iter Helpers */
|
/* Iter Helpers */
|
||||||
|
|
||||||
#define NI_LIST__FOREACH(lptr) \
|
#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) \
|
#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 != &(lptr)->head; \
|
||||||
it = tmp, tmp = it-> next)
|
it = tmp, tmp = it-> next)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user