summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 863ebc4)
raw | patch | inline | side by side (parent: 863ebc4)
author | Sebastian Harl <sh@tokkee.org> | |
Tue, 8 Jul 2014 20:08:55 +0000 (22:08 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Tue, 8 Jul 2014 20:08:55 +0000 (22:08 +0200) |
src/utils/avltree.c | patch | blob | history |
diff --git a/src/utils/avltree.c b/src/utils/avltree.c
index 95c004d32ffbe10ae39a31b9a146a80adccd2b41..7c810599135cf94658791fd1acb5c0a41f759852 100644 (file)
--- a/src/utils/avltree.c
+++ b/src/utils/avltree.c
#include "utils/avltree.h"
-#include <stdlib.h>
+#include <assert.h>
+#include <stdlib.h>
#include <pthread.h>
/*
if (! n)
return -1;
+ if (! tree->root) {
+ tree->root = n;
+ tree->size = 1;
+ return 0;
+ }
+
parent = tree->root;
- while (parent) {
+ while (42) {
+ assert(parent);
+
diff = tree->cmp(obj, parent->obj);
if (! diff) {
node_destroy(n);
}
}
- if (! parent) {
- /* new root */
- if (diff < 0)
- n->right = tree->root;
- else
- n->left = tree->root;
- tree->root = n;
- }
-
n->parent = parent;
++tree->size;