X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FHash.c;h=ada11a6a859ef59f941719f3dfb3e28fee869547;hb=28a464a75e14cece5db40f2765a29348273ff2d2;hp=876ba50deea4e4f9135ac621cab7fb5cb9d78bc0;hpb=9ac55e08e159d7a4647ab01e7872e69dd762f275;p=ghc-hetmet.git diff --git a/ghc/rts/Hash.c b/ghc/rts/Hash.c index 876ba50..ada11a6 100644 --- a/ghc/rts/Hash.c +++ b/ghc/rts/Hash.c @@ -1,5 +1,4 @@ /*----------------------------------------------------------------------------- - * $Id: Hash.c,v 1.3 2000/12/04 12:31:21 simonmar Exp $ * * (c) The AQUA Project, Glasgow University, 1995-1998 * (c) The GHC Team, 1999 @@ -9,10 +8,14 @@ * pp. 446 -- 457. * -------------------------------------------------------------------------- */ +#include "PosixSource.h" #include "Rts.h" #include "Hash.h" #include "RtsUtils.h" +#include +#include + #define HSEGSIZE 1024 /* Size of a single hash table segment */ /* Also the minimum size of a hash table */ #define HDIRSIZE 1024 /* Size of the segment directory */ @@ -242,9 +245,10 @@ insertHashTable(HashTable *table, StgWord key, void *data) int index; HashList *hl; - /* We want no duplicates */ - ASSERT(lookupHashTable(table, key) == NULL); - + // Disable this assert; sometimes it's useful to be able to + // overwrite entries in the hash table. + // ASSERT(lookupHashTable(table, key) == NULL); + /* When the average load gets too high, we expand the table */ if (++table->kcount >= HLOAD * table->bcount) expand(table); @@ -281,6 +285,7 @@ removeHashTable(HashTable *table, StgWord key, void *data) table->dir[segment][index] = hl->next; else prev->next = hl->next; + freeHashList(hl); table->kcount--; return hl->data; } @@ -320,11 +325,11 @@ freeHashTable(HashTable *table, void (*freeDataFun)(void *) ) } index--; } - free(table->dir[segment]); + stgFree(table->dir[segment]); segment--; index = HSEGSIZE - 1; } - free(table); + stgFree(table); } /* -----------------------------------------------------------------------------