src/tree.c

changeset 431
dcf01bb852f4
parent 426
9aa38cd4c992
child 453
bb144d08cd44
equal deleted inserted replaced
430:d4d643def2ac 431:dcf01bb852f4
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "cx/tree.h" 29 #include "cx/tree.h"
30 #include "cx/linked_list.h"
30 31
31 #define CX_TR_PTR(cur, off) ((void**)(((char*)cur)+off)) 32 #define CX_TR_PTR(cur, off) ((void**)(((char*)cur)+off))
32 33
33 void* cx_tree_last(void *node, ptrdiff_t loc_next) { 34 void* cx_tree_last(void *node, ptrdiff_t loc_next) {
34 void *last; 35 void *last;
64 ptrdiff_t loc_next, 65 ptrdiff_t loc_next,
65 void **children_begin, 66 void **children_begin,
66 void **children_end, 67 void **children_end,
67 void *new_node) 68 void *new_node)
68 { 69 {
69 return 1; 70 if(cx_linked_list_add(children_begin, children_end, loc_prev, loc_next, new_node)) {
71 return 1;
72 }
73 // optional field
74 if(loc_parent >= 0) {
75 *CX_TR_PTR(new_node, loc_parent) = parent;
76 }
77 return 0;
70 } 78 }

mercurial