diff options
| author | Simon Tatham <anakin@pobox.com> | 2004-06-12 20:31:03 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2004-06-12 20:31:03 +0000 |
| commit | a5d800d080a9eb557082042216636ac872eac7ec (patch) | |
| tree | bbc892a5a4e1da173dbbbe4358160aec96b4161d /tree234.c | |
| parent | 3ae295ca676ac0db275ad2cc1945fa0eca4a19bd (diff) | |
| download | halibut-a5d800d080a9eb557082042216636ac872eac7ec.zip halibut-a5d800d080a9eb557082042216636ac872eac7ec.tar.gz halibut-a5d800d080a9eb557082042216636ac872eac7ec.tar.bz2 halibut-a5d800d080a9eb557082042216636ac872eac7ec.tar.xz | |
Switch the memory allocation macros from the Halibut ones
(mknew/mknewa/resize) to the PuTTY ones (snew/snewn/sresize). snewn
and mknewa have their arguments opposite ways round; this may make
the change initially painful but in the long term will free me of a
nasty context switch every time I move between codebases. Also
sresize takes an explicit type operand which is used to cast the
return value from realloc, thus enforcing that it must be correct,
and arranging that if anyone tries to compile Halibut with a C++
compiler there should be a lot less pain.
[originally from svn r4276]
Diffstat (limited to 'tree234.c')
| -rw-r--r-- | tree234.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -34,7 +34,7 @@ #define smalloc malloc #define sfree free -#define mknew(typ) ( (typ *) smalloc (sizeof (typ)) ) +#define snew(typ) ( (typ *) smalloc (sizeof (typ)) ) #ifdef TEST #define LOG(x) (printf x) @@ -60,7 +60,7 @@ struct node234_Tag { * Create a 2-3-4 tree. */ tree234 *newtree234(cmpfn234 cmp) { - tree234 *ret = mknew(tree234); + tree234 *ret = snew(tree234); LOG(("created tree %p\n", ret)); ret->root = NULL; ret->cmp = cmp; @@ -187,7 +187,7 @@ static int add234_insert(node234 *left, void *e, node234 *right, 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)); /* @@ -283,7 +283,7 @@ static int add234_insert(node234 *left, void *e, node234 *right, return 0; /* root unchanged */ } else { LOG((" root is overloaded, split into two\n")); - (*root) = mknew(node234); + (*root) = snew(node234); (*root)->kids[0] = left; (*root)->counts[0] = lcount; (*root)->elems[0] = e; (*root)->kids[1] = right; (*root)->counts[1] = rcount; @@ -314,7 +314,7 @@ static void *add234_internal(tree234 *t, void *e, int index) { LOG(("adding element \"%s\" 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; @@ -1040,7 +1040,7 @@ static node234 *join234_internal(node234 *left, void *sep, * nodes. */ node234 *newroot; - newroot = mknew(node234); + newroot = snew(node234); newroot->kids[0] = left; newroot->counts[0] = countnode234(left); newroot->elems[0] = sep; newroot->kids[1] = right; newroot->counts[1] = countnode234(right); @@ -1215,7 +1215,7 @@ static node234 *split234_internal(tree234 *t, int index) { * new node pointers in halves[0] and halves[1], and go up * a level. */ - sib = mknew(node234); + sib = snew(node234); for (i = 0; i < 3; i++) { if (i+ki < 3 && n->elems[i+ki]) { sib->elems[i] = n->elems[i+ki]; @@ -1415,7 +1415,7 @@ tree234 *split234(tree234 *t, void *e, cmpfn234 cmp, int rel) { static node234 *copynode234(node234 *n, copyfn234 copyfn, void *copyfnstate) { int i; - node234 *n2 = mknew(node234); + node234 *n2 = snew(node234); for (i = 0; i < 3; i++) { if (n->elems[i] && copyfn) |