move dereference operation into macro

Fri, 08 Oct 2021 18:58:49 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 08 Oct 2021 18:58:49 +0200
changeset 472
18f964adad1b
parent 470
e5a4de4f1e03
child 473
1bd4b8c28722

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;
     }
 }

mercurial