Fri, 08 Oct 2021 18:58:49 +0200
move dereference operation into macro
src/tree.c | file | annotate | diff | comparison | revisions |
--- a/src/tree.c Wed Oct 06 14:24:52 2021 +0200 +++ b/src/tree.c Fri Oct 08 18:58:49 2021 +0200 @@ -29,14 +29,14 @@ #include "cx/tree.h" #include "cx/linked_list.h" -#define CX_TR_PTR(cur, off) ((void**)(((char*)cur)+off)) +#define CX_TR_PTR(cur, off) *((void**)(((char*)cur)+off)) void cx_tree_add_sibling(void *node, ptrdiff_t loc_prev, ptrdiff_t loc_next, ptrdiff_t loc_parent, void *new_node) { cx_linked_list_add(&node, NULL, loc_prev, loc_next, new_node); // optional parent link if (loc_parent >= 0) { - *CX_TR_PTR(new_node, loc_parent) = *CX_TR_PTR(node, loc_parent); + CX_TR_PTR(new_node, loc_parent) = CX_TR_PTR(node, loc_parent); } } @@ -47,6 +47,6 @@ // optional parent link if (loc_parent >= 0) { - *CX_TR_PTR(new_node, loc_parent) = parent; + CX_TR_PTR(new_node, loc_parent) = parent; } }