/*************************************************************************\ * Copyright (c) 2002 The University of Chicago, as Operator of Argonne * National Laboratory. * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS BASE Versions 3.13.7 * and higher are distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/
gpHash.c - General Purpose Hash Library
gphInitPvt - Initialize gphFind - Find an element taht has been hashed gphAdd - Add a new entry gphDelete - Delete an entry gphFreeMem - Free all memory allocated by gpHash gphDump - Dump current members typedef struct{ ELLNODE node; char *name; /*address of name placed in directory*/ void *pvtid; /*private name for subsystem user*/ void *userPvt; /*private for user*/ } GPHENTRY; void gphInitPvt(void **ppvt); GPHENTRY *gphFind(void *pvt,const char *name,void *pvtid); GPHENTRY *gphAdd(void *pvt,const char *name,void *pvtid); void gphDelete(void *pvt,const char *name,void *pvtid); void gphFreeMem(void *pvt); void gphDump(void *pvt); where : pvt - For private use by library. Caller must provide a "void *pvt" name - The character string that will be hashed and added to table pvtid - The name plus value of this pointer constitute unique entry
This library provides a general purpose directory of names that is accessed via a hash table. The hash table contains 256 entries. Each entry is a list of members that hash to the same value. The user can maintain seperate directories via the same table by having a different pvtid for each directory.
gphFind returns the address of the GPHENTRY describing the entry or NULL if name was not found. gphAdd returns the address of the new GPHENTRY describing the entry or NULL if name was already present.
gpHash.h
Fast Hashing of Variable Length Text Strings, Peter K. Pear- son, Communications of the ACM, June 1990