Select Git revision
hashtable.c
-
Henrik (Grubba) Grubbström authored
Rev: src/acconfig.h:1.19 Rev: src/alloca.c:1.2 Rev: src/array.c:1.31 Rev: src/array.h:1.12 Rev: src/backend.h:1.6 Rev: src/build_modlist_h:1.2 Rev: src/builtin_functions.h:1.7 Rev: src/callback.c:1.14 Rev: src/callback.h:1.7 Rev: src/compilation.h:1.8 Rev: src/constants.c:1.13 Rev: src/constants.h:1.6 Rev: src/cpp.c:1.21 Rev: src/cpp.h:1.4 Rev: src/crypt.c:1.2 Rev: src/cyclic.c:1.3 Rev: src/cyclic.h:1.3 Rev: src/dmalloc.h:1.5 Rev: src/docode.h:1.5 Rev: src/dynamic_buffer.c:1.8 Rev: src/dynamic_buffer.h:1.6 Rev: src/dynamic_load.c:1.25 Rev: src/dynamic_load.h:1.3 Rev: src/efun.h:1.3 Rev: src/encode.c:1.18 Rev: src/encode.h:1.2 Rev: src/error.c:1.14 Rev: src/error.h:1.14 Rev: src/fd_control.c:1.17 Rev: src/fd_control.h:1.3 Rev: src/fdlib.c:1.16 Rev: src/fdlib.h:1.13 Rev: src/fsort.c:1.9 Rev: src/fsort.h:1.2 Rev: src/fsort_template.h:1.3 Rev: src/gc.c:1.30 Rev: src/gc.h:1.16 Rev: src/global.h:1.20 Rev: src/hashtable.c:1.4 Rev: src/hashtable.h:1.5 Rev: src/install-sh:1.4 Rev: src/interpret.h:1.20 Rev: src/las.h:1.13 Rev: src/lex.h:1.10 Rev: src/main.h:1.7 Rev: src/mapping.h:1.10 Rev: src/module.c:1.8 Rev: src/module.h:1.4 Rev: src/module_support.c:1.9 Rev: src/module_support.h:1.6 Rev: src/modules/Gdbm/Makefile.in:1.3 Rev: src/modules/Gdbm/configure.in:1.2 Rev: src/modules/Gdbm/testsuite.in:1.4 Rev: src/modules/Gmp/Makefile.in:1.8 Rev: src/modules/Gmp/configure.in:1.2 Rev: src/modules/Gmp/gmp_machine.h.in:1.2 Rev: src/modules/Gmp/my_gmp.h:1.3 Rev: src/modules/Gmp/next_prime.c:1.6 Rev: src/modules/Gmp/prime_table.c:1.3 Rev: src/modules/Gmp/testsuite.in:1.12 Rev: src/modules/Gz/Makefile.in:1.3 Rev: src/modules/Gz/configure.in:1.10 Rev: src/modules/Gz/testsuite.in:1.4 Rev: src/modules/Image/Makefile:1.8 Rev: src/modules/Image/Makefile.in:1.14 Rev: src/modules/Image/configure.in:1.8 Rev: src/modules/Image/encodings/Makefile.in:1.14 Rev: src/modules/Image/encodings/configure.in:1.4 Rev: src/modules/Image/testsuite.in:1.5 Rev: src/modules/MIME/Makefile.in:1.2 Rev: src/modules/MIME/acconfig.h:1.2 Rev: src/modules/MIME/configure.in:1.3 Rev: src/modules/MIME/testsuite.in:1.5 Rev: src/modules/Msql/Makefile.in:1.3 Rev: src/modules/Msql/test_msqlmod.pike:1.2 Rev: src/modules/Mysql/dummy.c:1.4 Rev: src/modules/Pipe/Makefile.in:1.3 Rev: src/modules/Pipe/configure.in:1.4 Rev: src/modules/Postgres/extras/test_notify.pike:1.2 Rev: src/modules/Postgres/extras/test_schema.pike:1.2 Rev: src/modules/Postgres/pg_types.h:1.3 Rev: src/modules/Postgres/pgresult.c:1.5 Rev: src/modules/Postgres/pgresult.h:1.2 Rev: src/modules/Regexp/Makefile.in:1.5 Rev: src/modules/Regexp/configure.in:1.5 Rev: src/modules/Regexp/glue.c:1.10 Rev: src/modules/Regexp/pike_regexp.c:1.12 Rev: src/modules/Regexp/pike_regexp.h:1.3 Rev: src/modules/Regexp/testsuite.in:1.3 Rev: src/modules/Ssleay/Makefile.in:1.3 Rev: src/modules/Ssleay/acconfig.h:1.2 Rev: src/modules/Ssleay/configure.in:1.4 Rev: src/modules/Yp/Makefile.in:1.3 Rev: src/modules/Yp/configure.in:1.5 Rev: src/modules/Yp/yp.c:1.12 Rev: src/modules/_Crypto/.build_lobotomized_crypto:1.6 Rev: src/modules/_Crypto/.exportable_files:1.3 Rev: src/modules/_Crypto/Makefile.in:1.16 Rev: src/modules/_Crypto/configure.in:1.5 Rev: src/modules/_Crypto/include/.exportable_files:1.2 Rev: src/modules/_Crypto/include/RCSID.h:1.6 Rev: src/modules/_Crypto/include/cast.h:1.2 Rev: src/modules/_Crypto/include/crypto_types.h:1.5 Rev: src/modules/_Crypto/include/idea.h:1.4 Rev: src/modules/_Crypto/include/md5.h:1.2 Rev: src/modules/_Crypto/include/rc4.h:1.3 Rev: src/modules/_Crypto/include/sha.h:1.4 Rev: src/modules/_Crypto/lib/.exportable_files:1.2 Rev: src/modules/_Crypto/lib/cast.c:1.2 Rev: src/modules/_Crypto/lib/cast_sboxes.h:1.2 Rev: src/modules/_Crypto/precompiled_crypto.h:1.17 Rev: src/modules/_Crypto/sha.c:1.10 Rev: src/modules/_Image_PNG/Makefile.in:1.2 Rev: src/modules/_Image_PNG/configure.in:1.2 Rev: src/modules/_Image_PNG/testsuite.in:1.3 Rev: src/modules/_Image_XFace/Makefile.in:1.2 Rev: src/modules/_Image_XFace/configure.in:1.2 Rev: src/modules/_Image_XFace/testsuite.in:1.2 Rev: src/modules/configure.in:1.5 Rev: src/modules/module_configure.in:1.5 Rev: src/modules/module_makefile:1.3 Rev: src/multiset.c:1.10 Rev: src/multiset.h:1.7 Rev: src/object.h:1.17 Rev: src/opcodes.c:1.16 Rev: src/opcodes.h:1.4 Rev: src/operators.h:1.4 Rev: src/otable.h:1.2 Rev: src/peep.c:1.19 Rev: src/peep.h:1.4 Rev: src/peep.in:1.12 Rev: src/pike_macros.h:1.6 Rev: src/pike_memory.c:1.18 Rev: src/pike_memory.h:1.4 Rev: src/pike_types.h:1.11 Rev: src/port.c:1.15 Rev: src/port.h:1.18 Rev: src/program.h:1.35 Rev: src/run_autoconfig:1.21 Rev: src/rusage.c:1.10 Rev: src/rusage.h:1.3 Rev: src/signal_handler.c:1.41 Rev: src/signal_handler.h:1.6 Rev: src/stralloc.c:1.30 Rev: src/stralloc.h:1.15 Rev: src/stuff.c:1.6 Rev: src/stuff.h:1.5 Rev: src/svalue.c:1.21 Rev: src/svalue.h:1.14 Rev: src/threads.h:1.40 Rev: src/time_stuff.h:1.8 Rev: src/ualarm.c:1.2 Rev: src/version.c:1.34 Rev: src/version.h:1.3
Henrik (Grubba) Grubbström authoredRev: src/acconfig.h:1.19 Rev: src/alloca.c:1.2 Rev: src/array.c:1.31 Rev: src/array.h:1.12 Rev: src/backend.h:1.6 Rev: src/build_modlist_h:1.2 Rev: src/builtin_functions.h:1.7 Rev: src/callback.c:1.14 Rev: src/callback.h:1.7 Rev: src/compilation.h:1.8 Rev: src/constants.c:1.13 Rev: src/constants.h:1.6 Rev: src/cpp.c:1.21 Rev: src/cpp.h:1.4 Rev: src/crypt.c:1.2 Rev: src/cyclic.c:1.3 Rev: src/cyclic.h:1.3 Rev: src/dmalloc.h:1.5 Rev: src/docode.h:1.5 Rev: src/dynamic_buffer.c:1.8 Rev: src/dynamic_buffer.h:1.6 Rev: src/dynamic_load.c:1.25 Rev: src/dynamic_load.h:1.3 Rev: src/efun.h:1.3 Rev: src/encode.c:1.18 Rev: src/encode.h:1.2 Rev: src/error.c:1.14 Rev: src/error.h:1.14 Rev: src/fd_control.c:1.17 Rev: src/fd_control.h:1.3 Rev: src/fdlib.c:1.16 Rev: src/fdlib.h:1.13 Rev: src/fsort.c:1.9 Rev: src/fsort.h:1.2 Rev: src/fsort_template.h:1.3 Rev: src/gc.c:1.30 Rev: src/gc.h:1.16 Rev: src/global.h:1.20 Rev: src/hashtable.c:1.4 Rev: src/hashtable.h:1.5 Rev: src/install-sh:1.4 Rev: src/interpret.h:1.20 Rev: src/las.h:1.13 Rev: src/lex.h:1.10 Rev: src/main.h:1.7 Rev: src/mapping.h:1.10 Rev: src/module.c:1.8 Rev: src/module.h:1.4 Rev: src/module_support.c:1.9 Rev: src/module_support.h:1.6 Rev: src/modules/Gdbm/Makefile.in:1.3 Rev: src/modules/Gdbm/configure.in:1.2 Rev: src/modules/Gdbm/testsuite.in:1.4 Rev: src/modules/Gmp/Makefile.in:1.8 Rev: src/modules/Gmp/configure.in:1.2 Rev: src/modules/Gmp/gmp_machine.h.in:1.2 Rev: src/modules/Gmp/my_gmp.h:1.3 Rev: src/modules/Gmp/next_prime.c:1.6 Rev: src/modules/Gmp/prime_table.c:1.3 Rev: src/modules/Gmp/testsuite.in:1.12 Rev: src/modules/Gz/Makefile.in:1.3 Rev: src/modules/Gz/configure.in:1.10 Rev: src/modules/Gz/testsuite.in:1.4 Rev: src/modules/Image/Makefile:1.8 Rev: src/modules/Image/Makefile.in:1.14 Rev: src/modules/Image/configure.in:1.8 Rev: src/modules/Image/encodings/Makefile.in:1.14 Rev: src/modules/Image/encodings/configure.in:1.4 Rev: src/modules/Image/testsuite.in:1.5 Rev: src/modules/MIME/Makefile.in:1.2 Rev: src/modules/MIME/acconfig.h:1.2 Rev: src/modules/MIME/configure.in:1.3 Rev: src/modules/MIME/testsuite.in:1.5 Rev: src/modules/Msql/Makefile.in:1.3 Rev: src/modules/Msql/test_msqlmod.pike:1.2 Rev: src/modules/Mysql/dummy.c:1.4 Rev: src/modules/Pipe/Makefile.in:1.3 Rev: src/modules/Pipe/configure.in:1.4 Rev: src/modules/Postgres/extras/test_notify.pike:1.2 Rev: src/modules/Postgres/extras/test_schema.pike:1.2 Rev: src/modules/Postgres/pg_types.h:1.3 Rev: src/modules/Postgres/pgresult.c:1.5 Rev: src/modules/Postgres/pgresult.h:1.2 Rev: src/modules/Regexp/Makefile.in:1.5 Rev: src/modules/Regexp/configure.in:1.5 Rev: src/modules/Regexp/glue.c:1.10 Rev: src/modules/Regexp/pike_regexp.c:1.12 Rev: src/modules/Regexp/pike_regexp.h:1.3 Rev: src/modules/Regexp/testsuite.in:1.3 Rev: src/modules/Ssleay/Makefile.in:1.3 Rev: src/modules/Ssleay/acconfig.h:1.2 Rev: src/modules/Ssleay/configure.in:1.4 Rev: src/modules/Yp/Makefile.in:1.3 Rev: src/modules/Yp/configure.in:1.5 Rev: src/modules/Yp/yp.c:1.12 Rev: src/modules/_Crypto/.build_lobotomized_crypto:1.6 Rev: src/modules/_Crypto/.exportable_files:1.3 Rev: src/modules/_Crypto/Makefile.in:1.16 Rev: src/modules/_Crypto/configure.in:1.5 Rev: src/modules/_Crypto/include/.exportable_files:1.2 Rev: src/modules/_Crypto/include/RCSID.h:1.6 Rev: src/modules/_Crypto/include/cast.h:1.2 Rev: src/modules/_Crypto/include/crypto_types.h:1.5 Rev: src/modules/_Crypto/include/idea.h:1.4 Rev: src/modules/_Crypto/include/md5.h:1.2 Rev: src/modules/_Crypto/include/rc4.h:1.3 Rev: src/modules/_Crypto/include/sha.h:1.4 Rev: src/modules/_Crypto/lib/.exportable_files:1.2 Rev: src/modules/_Crypto/lib/cast.c:1.2 Rev: src/modules/_Crypto/lib/cast_sboxes.h:1.2 Rev: src/modules/_Crypto/precompiled_crypto.h:1.17 Rev: src/modules/_Crypto/sha.c:1.10 Rev: src/modules/_Image_PNG/Makefile.in:1.2 Rev: src/modules/_Image_PNG/configure.in:1.2 Rev: src/modules/_Image_PNG/testsuite.in:1.3 Rev: src/modules/_Image_XFace/Makefile.in:1.2 Rev: src/modules/_Image_XFace/configure.in:1.2 Rev: src/modules/_Image_XFace/testsuite.in:1.2 Rev: src/modules/configure.in:1.5 Rev: src/modules/module_configure.in:1.5 Rev: src/modules/module_makefile:1.3 Rev: src/multiset.c:1.10 Rev: src/multiset.h:1.7 Rev: src/object.h:1.17 Rev: src/opcodes.c:1.16 Rev: src/opcodes.h:1.4 Rev: src/operators.h:1.4 Rev: src/otable.h:1.2 Rev: src/peep.c:1.19 Rev: src/peep.h:1.4 Rev: src/peep.in:1.12 Rev: src/pike_macros.h:1.6 Rev: src/pike_memory.c:1.18 Rev: src/pike_memory.h:1.4 Rev: src/pike_types.h:1.11 Rev: src/port.c:1.15 Rev: src/port.h:1.18 Rev: src/program.h:1.35 Rev: src/run_autoconfig:1.21 Rev: src/rusage.c:1.10 Rev: src/rusage.h:1.3 Rev: src/signal_handler.c:1.41 Rev: src/signal_handler.h:1.6 Rev: src/stralloc.c:1.30 Rev: src/stralloc.h:1.15 Rev: src/stuff.c:1.6 Rev: src/stuff.h:1.5 Rev: src/svalue.c:1.21 Rev: src/svalue.h:1.14 Rev: src/threads.h:1.40 Rev: src/time_stuff.h:1.8 Rev: src/ualarm.c:1.2 Rev: src/version.c:1.34 Rev: src/version.h:1.3
hashtable.c 3.60 KiB
/*\
||| This file a part of Pike, and is copyright by Fredrik Hubinette
||| Pike is distributed as GPL (General Public License)
||| See the files COPYING and DISCLAIMER for more information.
\*/
#include "global.h"
#include "hashtable.h"
#include "stralloc.h"
#include "stuff.h"
#include "error.h"
RCSID("$Id: hashtable.c,v 1.4 1998/03/28 15:14:56 grubba Exp $");
static unsigned INT32 gobble(struct pike_string *s)
{
unsigned INT32 i;
i=my_hash_string(s);
i+=i >> 3;
i+=i >> 7;
i+=i >> 12;
return i;
}
/*
* Search hash for a specific string.
*/
struct hash_entry *hash_lookup(struct hash_table *h, struct pike_string *s)
{
struct hash_entry *e, **prev, **base;
if(!h) return 0;
base = prev = h->htable + (gobble(s) & h->mask);
for( ;(e = *prev); prev= &e->next)
{
if(s == e->s)
{
/* Teleport entry to beginning of line */
*prev = e->next;
e->next = *base;
*base = e;
/* Entry arrives in a puff of smoke. */
return e;
}
}
return 0;
}
/*
* We want to keep the order of the hash chain, as it has been carefully
* built up to be fast.
*/
static void rehash_list_backwards(struct hash_table *h,
struct hash_entry *n)
{
struct hash_entry **base;
if(!n) return;
rehash_list_backwards(h,n->next);
base=h->htable + (gobble(n->s) & h->mask);
n->next = *base;
*base=n;
}
/*
* create a new, empty hashable
*/
struct hash_table *create_hash_table(void)
{
struct hash_table *new;
new=(struct hash_table *)calloc(1,sizeof(struct hash_table)+