X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/18756bee6a2b8aa06f001bce6843bce5b2dfb0b0..6f444bda1b7deb31cf7fb2395cb0993c3e3b8c42:/sym.c diff --git a/sym.c b/sym.c index 3aea8c7..a3c9b86 100644 --- a/sym.c +++ b/sym.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: sym.c,v 1.13 2001/01/25 21:14:49 mdw Exp $ + * $Id: sym.c,v 1.14 2003/12/15 20:53:47 mdw Exp $ * * Symbol table management * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: sym.c,v $ + * Revision 1.14 2003/12/15 20:53:47 mdw + * Add global unihash table; use universal hashing instead of CRC. + * * Revision 1.13 2001/01/25 21:14:49 mdw * Always add a terminating null, and don't count it in the length. * @@ -88,11 +91,11 @@ #include "alloc.h" #include "arena.h" #include "bits.h" -#include "crc32.h" #include "exc.h" #include "hash.h" #include "sub.h" #include "sym.h" +#include "unihash.h" /*----- Main code ---------------------------------------------------------*/ @@ -141,7 +144,7 @@ void sym_destroy(sym_table *t) /* --- @sym_find@ --- * * * Arguments: @sym_table *t@ = pointer to symbol table in question - * @const char *n@ = pointer to symbol table to look up + * @const char *n@ = pointer to symbol name to look up * @long l@ = length of the name string or negative to measure * @size_t sz@ = size of desired symbol object, or zero * @unsigned *f@ = pointer to a flag, or null. @@ -179,7 +182,7 @@ void *sym_find(sym_table *t, const char *n, long l, size_t sz, unsigned *f) /* --- Find the correct bin --- */ len = l < 0 ? strlen(n) : l; - CRC32(hash, 0, n, len); + hash = UNIHASH(&unihash_global, n, len); bin = HASH_BIN(&t->t, hash); /* --- Search the bin list --- */