chiark
/
gitweb
/
~mdw
/
mLib
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
The callback function can free the @bres_client@ structure! Make sure we
[mLib]
/
hash.c
diff --git
a/hash.c
b/hash.c
index 96c150bf7c9ca09a9c20eea77f5f1e68e4657979..d18cc003bcebf60bd2344530748b7964e1ca4c0e 100644
(file)
--- a/
hash.c
+++ b/
hash.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: hash.c,v 1.
1 1999/08/02 14:45:48
mdw Exp $
+ * $Id: hash.c,v 1.
4 2004/04/08 01:36:11
mdw Exp $
*
* General hashtable infrastructure
*
*
* General hashtable infrastructure
*
@@
-27,14
+27,6
@@
* MA 02111-1307, USA.
*/
* MA 02111-1307, USA.
*/
-/*----- Revision history --------------------------------------------------*
- *
- * $Log: hash.c,v $
- * Revision 1.1 1999/08/02 14:45:48 mdw
- * Break low-level hashtable code out from sym.
- *
- */
-
/*----- Header files ------------------------------------------------------*/
#include <stdio.h>
/*----- Header files ------------------------------------------------------*/
#include <stdio.h>
@@
-42,10
+34,10
@@
#include <string.h>
#include "alloc.h"
#include <string.h>
#include "alloc.h"
+#include "arena.h"
#include "bits.h"
#include "exc.h"
#include "hash.h"
#include "bits.h"
#include "exc.h"
#include "hash.h"
-#include "track.h"
/*----- Main code ---------------------------------------------------------*/
/*----- Main code ---------------------------------------------------------*/
@@
-64,13
+56,12
@@
void hash_create(hash_table *t, size_t n)
{
hash_base **v;
void hash_create(hash_table *t, size_t n)
{
hash_base **v;
- TRACK_CTX("hashtable creation");
-
TRACK_PUSH
;
- t->v = x
malloc(
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;
t->mask = n - 1;
for (v = t->v; n; v++, n--)
*v = 0;
- TRACK_POP;
}
/* --- @hash_destroy@ --- *
}
/* --- @hash_destroy@ --- *
@@
-85,10
+76,7
@@
void hash_create(hash_table *t, size_t n)
void hash_destroy(hash_table *t)
{
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@ --- *
}
/* --- @hash_bin@ --- *
@@
-123,15
+111,11
@@
int hash_extend(hash_table *t)
uint32 m = t->mask + 1;
size_t i;
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 --- */
/* --- 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,
+ 2 * m * sizeof(hash_base *),
+ m * sizeof(hash_base *))) == 0) {
return (0);
}
t->v = v;
return (0);
}
t->v = v;
@@
-156,7
+140,6
@@
int hash_extend(hash_table *t)
*q = 0;
}
*q = 0;
}
- TRACK_POP;
return (1);
}
return (1);
}