From 7f5473b3cc392b9b810378e7f4620451ad05bf91 Mon Sep 17 00:00:00 2001 From: "Jordan K. Hubbard" Date: Sun, 26 Mar 1995 10:12:53 +0000 Subject: [PATCH] add strhash.h for libc's new string hashing function. --- include/Makefile | 6 ++--- include/strhash.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 include/strhash.h diff --git a/include/Makefile b/include/Makefile index b9bded1a0c4b..9cbdddd25b0e 100644 --- a/include/Makefile +++ b/include/Makefile @@ -1,5 +1,5 @@ # From: @(#)Makefile 8.2 (Berkeley) 1/4/94 -# $Id: Makefile,v 1.22 1995/03/19 07:25:17 phk Exp $ +# $Id: Makefile,v 1.23 1995/03/22 07:29:58 phk Exp $ # # Doing a make install builds /usr/include # @@ -11,8 +11,8 @@ all depend lint tags: SUBDIR= rpcsvc # XXX MISSING: mp.h FILES= a.out.h ar.h assert.h bitstring.h ctype.h db.h dirent.h disktab.h \ - err.h f2c.h fnmatch.h fstab.h fts.h glob.h grp.h histedit.h kvm.h \ - limits.h link.h locale.h malloc.h memory.h mpool.h ndbm.h \ + err.h f2c.h fnmatch.h fstab.h fts.h glob.h grp.h strhash.h histedit.h \ + kvm.h limits.h link.h locale.h malloc.h memory.h mpool.h ndbm.h \ netdb.h nlist.h paths.h pwd.h ranlib.h regex.h regexp.h \ resolv.h rune.h runetype.h setjmp.h sgtty.h signal.h \ stab.h stddef.h stdio.h stdlib.h string.h strings.h struct.h \ diff --git a/include/strhash.h b/include/strhash.h new file mode 100644 index 000000000000..97e50a80c0dd --- /dev/null +++ b/include/strhash.h @@ -0,0 +1,64 @@ +#ifndef _STRHASH_H_INCLUDE +#define _STRHASH_H_INCLUDE + +/* $Header: /home/ncvs/src/usr.bin/dmenu/hash.h,v 1.2 1995/03/21 06:39:04 jkh Exp $ */ + +/* + * + * Copyright 1990 + * Terry Jones & Jordan Hubbard + * + * PCS Computer Systeme, GmbH. + * Munich, West Germany + * + * + * All rights reserved. + * + * This is unsupported software and is subject to change without notice. + * the author makes no representations about the suitability of this software + * for any purpose. It is supplied "as is" without express or implied + * warranty. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the author not be used in + * advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. + * + */ + +/* + * This is the definition file for hash.c. The plunderer from down-under + * did the code, I just helped define the spec. That's why his name gets + * to go first. + */ + +#define HASH_SZ 97 + +typedef struct _node { + char *key; + void *data; + struct _node *next; +} hash_node; + +typedef struct { + int size; + hash_node **buckets; +} hash_table; + +hash_table *hash_create(int size); +void hash_destroy(hash_table *table, char *key, + void (*nukefunc)(char *k, void *d)); +void *hash_search(hash_table *table, char *key, void *datum, + void (*replace_func)(void *d)); +void hash_traverse(hash_table *table, + int (*func)(char *k, void *d, void *arg), void *arg); +void hash_purge(hash_table *table, void (*purge_func)(char *k, void *d)); + +#ifdef HASH_STATS +extern void hash_stats(); +#endif + +#endif /* _STRHASH_H_INCLUDE */