Sun, 07 Feb 2021 21:14:39 +0100
use C99 flexible array to mark the node's payload
src/linked_list.c | file | annotate | diff | comparison | revisions |
1.1 --- a/src/linked_list.c Sun Feb 07 21:03:30 2021 +0100 1.2 +++ b/src/linked_list.c Sun Feb 07 21:14:39 2021 +0100 1.3 @@ -82,7 +82,7 @@ 1.4 struct cx_linked_list_node { 1.5 void *prev; 1.6 void *next; 1.7 - int payload; 1.8 + char payload[]; 1.9 }; 1.10 1.11 typedef struct { 1.12 @@ -95,7 +95,7 @@ 1.13 CxAllocator allocator = list->allocator; 1.14 1.15 struct cx_linked_list_node *node = cxMalloc(allocator, 1.16 - sizeof(struct cx_linked_list_node) - sizeof(int) + list->itemsize); 1.17 + sizeof(struct cx_linked_list_node) + list->itemsize); 1.18 if (node == NULL) 1.19 return 1; 1.20