X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/32874aeac8dacbca26663777b39a79efc5d8dc4b..56668e6dca80813a2c9f03d4c02ed20e22f1061b:/tree234.c diff --git a/tree234.c b/tree234.c index 0837dc67..84e8c187 100644 --- a/tree234.c +++ b/tree234.c @@ -29,13 +29,9 @@ #include #include +#include "puttymem.h" #include "tree234.h" -#define smalloc malloc -#define sfree free - -#define mknew(typ) ( (typ *) smalloc (sizeof (typ)) ) - #ifdef TEST #define LOG(x) (printf x) #else @@ -61,7 +57,7 @@ struct node234_Tag { */ tree234 *newtree234(cmpfn234 cmp) { - tree234 *ret = mknew(tree234); + tree234 *ret = snew(tree234); LOG(("created tree %p\n", ret)); ret->root = NULL; ret->cmp = cmp; @@ -128,7 +124,7 @@ static void *add234_internal(tree234 * t, void *e, int index) LOG(("adding node %p to tree %p\n", e, t)); if (t->root == NULL) { - t->root = mknew(node234); + t->root = snew(node234); t->root->elems[1] = t->root->elems[2] = NULL; t->root->kids[0] = t->root->kids[1] = NULL; t->root->kids[2] = t->root->kids[3] = NULL; @@ -140,6 +136,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; @@ -300,7 +297,7 @@ static void *add234_internal(tree234 * t, void *e, int index) LOG((" done\n")); break; } else { - node234 *m = mknew(node234); + node234 *m = snew(node234); m->parent = n->parent; LOG((" splitting a 4-node; created new node %p\n", m)); /* @@ -423,7 +420,7 @@ static void *add234_internal(tree234 * t, void *e, int index) } } else { LOG((" root is overloaded, split into two\n")); - t->root = mknew(node234); + t->root = snew(node234); t->root->kids[0] = left; t->root->counts[0] = lcount; t->root->elems[0] = e; @@ -1012,8 +1009,6 @@ void *del234(tree234 * t, void *e) #include -#define srealloc realloc - /* * Error reporting function. */ @@ -1201,8 +1196,7 @@ void internal_addtest(void *elem, int index, void *realret) if (arraysize < arraylen + 1) { arraysize = arraylen + 1 + 256; - array = (array == NULL ? smalloc(arraysize * sizeof(*array)) : - srealloc(array, arraysize * sizeof(*array))); + array = sresize(array, arraysize, void *); } i = index;