+
+static int actlist_splay_walk(actlist_t*a, segment_t*s, segment_t**ss, segment_t*parent)
+{
+ if(!s) return 1;
+ if(parent != s->parent) {
+ fprintf(stderr, "Parent mismatch in [%d]: [%d] != [%d]\n", SEGNR(s), SEGNR(parent), SEGNR(s->parent));
+ return 0;
+ }
+ if(!actlist_splay_walk(a, s->leftchild, ss, s)) return 0;
+ if(s != *ss) {
+ fprintf(stderr, "[%d] != [%d]\n", SEGNR(s), SEGNR(*ss));
+ return 0;
+ }
+ (*ss) = (*ss)->right;
+ if(!actlist_splay_walk(a, s->rightchild, ss, s)) return 0;
+ return 1;
+}
+
+static int actlist_splay_verify(actlist_t*a)
+{
+ segment_t*c = a->list;
+ if(!actlist_splay_walk(a, a->root, &c, 0)) return 0;
+ if(c) return 0;
+ return 1;
+}
+static void actlist_splay_dump2(actlist_t*a, segment_t*s, char*mid, char*up, char*down)
+{
+ if(!s) return;
+
+ if(s->leftchild || s->rightchild) {
+ int t;
+
+ if(s->leftchild) {
+ char*o3 = malloc(strlen(up)+3);
+ strcpy(o3, up);strcat(o3, "+-");
+ char*newup = malloc(strlen(up)+3);
+ strcpy(newup, up);strcat(newup, "| ");
+ char*newup2 = malloc(strlen(up)+3);
+ strcpy(newup2, up);strcat(newup2, " ");
+ actlist_splay_dump2(a, s->leftchild, o3, newup2, newup);
+ fprintf(stderr, "%s| \n", up);
+ free(newup);
+ free(newup2);
+ free(o3);
+ }
+ fprintf(stderr, "%s[%d]\n", mid, SEGNR(s));
+ if(s->rightchild) {
+ char*o3 = malloc(strlen(down)+3);
+ strcpy(o3, down);strcat(o3, "+-");
+ char*newdown = malloc(strlen(down)+3);
+ strcpy(newdown, down);strcat(newdown, "| ");
+ char*newdown2 = malloc(strlen(down)+3);
+ strcpy(newdown2, down);strcat(newdown2, " ");
+ fprintf(stderr, "%s| \n", down);
+ actlist_splay_dump2(a, s->rightchild, o3, newdown, newdown2);
+ free(newdown);
+ free(newdown2);
+ free(o3);
+ }
+ } else {
+ fprintf(stderr, "%s[%d]\n", mid, SEGNR(s));
+ }
+}
+static void actlist_splay_dump(actlist_t*a)
+{
+ actlist_splay_dump2(a, a->root, "", "", "");
+}
+
+