X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=tree234.c;h=f1c0c2edbef63178f5a5f183a558b2858762ea3d;hb=ac5b13398f47c99cc189eed4538abcccc3c18300;hp=b5895d0e314e6d557cc7a47ccd68968588c20b2c;hpb=d36a4c3685f17057ba2c80ac471c1284b615469f;p=PuTTY.git diff --git a/tree234.c b/tree234.c index b5895d0e..f1c0c2ed 100644 --- a/tree234.c +++ b/tree234.c @@ -29,12 +29,18 @@ #include #include -#include "puttymem.h" #include "tree234.h" #ifdef TEST #define LOG(x) (printf x) +#define snew(type) ((type *)malloc(sizeof(type))) +#define snewn(n, type) ((type *)malloc((n) * sizeof(type))) +#define sresize(ptr, n, type) \ + ((type *)realloc(sizeof((type *)0 == (ptr)) ? (ptr) : (ptr), \ + (n) * sizeof(type))) +#define sfree(ptr) free(ptr) #else +#include "puttymem.h" #define LOG(x) #endif @@ -136,6 +142,7 @@ static void *add234_internal(tree234 * t, void *e, int index) return orig_e; } + n = NULL; /* placate gcc; will always be set below since t->root != NULL */ np = &t->root; while (*np) { int childnum; @@ -219,7 +226,7 @@ static void *add234_internal(tree234 * t, void *e, int index) n->kids[2], n->counts[2], n->elems[2], n->kids[3], n->counts[3])); LOG((" need to insert %p/%d [%p] %p/%d at position %d\n", - left, lcount, e, right, rcount, np - n->kids)); + left, lcount, e, right, rcount, (int)(np - n->kids))); if (n->elems[1] == NULL) { /* * Insert in a 2-node; simple. @@ -1468,7 +1475,8 @@ int main(void) printf("cleanup: tree size %d\n", count234(tree)); j = randomnumber(&seed); j %= count234(tree); - printf("deleting string %s from index %d\n", array[j], j); + printf("deleting string %s from index %d\n", + (const char *)array[j], j); delpostest(j); }