Compare commits
2 Commits
f75c8141d4
...
e498c821bf
| Author | SHA1 | Date | |
|---|---|---|---|
| e498c821bf | |||
| f13a774766 |
@@ -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)
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ int main (void)
|
||||
size_t test_size = 10;
|
||||
for(size_t i = 0; i < test_size; i++) {
|
||||
test_data* t = malloc(sizeof(test_data));
|
||||
printf("n = %d allocated data...link at %p...\n", i, &t->link);
|
||||
printf("n = %d allocated data at %p...test_data.link at %p...\n", i, &t, &t->link);
|
||||
|
||||
t->data1 = rand() % UINT64_MAX;
|
||||
t->data2 = rand() % UINT64_MAX;
|
||||
|
||||
Reference in New Issue
Block a user