X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/03d53b73fc6663cef4493cfda7193c958557c240..c71fde7b8d2d85dc1b8352090743c99ad787b4dd:/hash.c diff --git a/hash.c b/hash.c index 96c150b..3945755 100644 --- a/hash.c +++ b/hash.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: hash.c,v 1.1 1999/08/02 14:45:48 mdw Exp $ + * $Id: hash.c,v 1.2 2000/06/17 10:37:39 mdw Exp $ * * General hashtable infrastructure * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: hash.c,v $ + * Revision 1.2 2000/06/17 10:37:39 mdw + * Add support for arena management. + * * Revision 1.1 1999/08/02 14:45:48 mdw * Break low-level hashtable code out from sym. * @@ -42,10 +45,10 @@ #include #include "alloc.h" +#include "arena.h" #include "bits.h" #include "exc.h" #include "hash.h" -#include "track.h" /*----- Main code ---------------------------------------------------------*/ @@ -64,13 +67,12 @@ void hash_create(hash_table *t, size_t n) { hash_base **v; - TRACK_CTX("hashtable creation"); - TRACK_PUSH; - t->v = xmalloc(n * sizeof(hash_base *)); + + t->a = arena_global; + t->v = x_alloc(t->a, n * sizeof(hash_base *)); t->mask = n - 1; for (v = t->v; n; v++, n--) *v = 0; - TRACK_POP; } /* --- @hash_destroy@ --- * @@ -85,10 +87,7 @@ void hash_create(hash_table *t, size_t n) void hash_destroy(hash_table *t) { - TRACK_CTX("hashtable destruction"); - TRACK_PUSH; - free(t->v); - TRACK_POP; + x_free(t->a, t->v); } /* --- @hash_bin@ --- * @@ -123,15 +122,9 @@ int hash_extend(hash_table *t) uint32 m = t->mask + 1; size_t i; - /* --- Push in a tracking context --- */ - - TRACK_CTX("hashtable extension"); - TRACK_PUSH; - /* --- Allocate a new hash bin vector --- */ - if ((v = realloc(t->v, m * 2 * sizeof(hash_base *))) == 0) { - TRACK_POP; + if ((v = A_REALLOC(t->a, t->v, m * 2 * sizeof(hash_base *))) == 0) { return (0); } t->v = v; @@ -156,7 +149,6 @@ int hash_extend(hash_table *t) *q = 0; } - TRACK_POP; return (1); }