X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FHash.h;h=ad55953da4c56198eb57cbe395f558371e355601;hb=2322bc9a89a9d8a6132a6818ccff6f665d7ed7f1;hp=74ff3217eb3797d4d5fb28c62ae6b0a16c4af45b;hpb=1b28d4e1f43185ad8c8e7407c66413e1b358402b;p=ghc-hetmet.git diff --git a/ghc/rts/Hash.h b/ghc/rts/Hash.h index 74ff321..ad55953 100644 --- a/ghc/rts/Hash.h +++ b/ghc/rts/Hash.h @@ -1,5 +1,4 @@ /*----------------------------------------------------------------------------- - * $Id: Hash.h,v 1.2 2000/01/13 14:34:03 hwloidl Exp $ * * (c) The GHC Team, 1999 * @@ -7,11 +6,35 @@ * * -------------------------------------------------------------------------- */ +#ifndef HASH_H +#define HASH_H + typedef struct hashtable HashTable; /* abstract */ +/* Hash table access where the keys are StgWords */ +HashTable * allocHashTable ( void ); void * lookupHashTable ( HashTable *table, StgWord key ); void insertHashTable ( HashTable *table, StgWord key, void *data ); void * removeHashTable ( HashTable *table, StgWord key, void *data ); -void freeHashTable ( HashTable *table, void (*freeDataFun)(void *) ); -HashTable * allocHashTable ( void ); + +/* Hash table access where the keys are C strings (the strings are + * assumed to be allocated by the caller, and mustn't be deallocated + * until the corresponding hash table entry has been removed). + */ +HashTable * allocStrHashTable ( void ); + +#define lookupStrHashTable(table, key) \ + (lookupHashTable(table, (StgWord)key)) + +#define insertStrHashTable(table, key, data) \ + (insertHashTable(table, (StgWord)key, data)) + +#define removeStrHashTable(table, key, data) \ + (removeHashTable(table, (StgWord)key, data)) + +/* Freeing hash tables + */ +void freeHashTable ( HashTable *table, void (*freeDataFun)(void *) ); + +#endif /* HASH_H */