/*-----------------------------------------------------------------------------
- * $Id: Hash.c,v 1.5 2001/06/27 11:29:10 sewardj Exp $
*
* (c) The AQUA Project, Glasgow University, 1995-1998
* (c) The GHC Team, 1999
* pp. 446 -- 457.
* -------------------------------------------------------------------------- */
+#include "PosixSource.h"
#include "Rts.h"
#include "Hash.h"
#include "RtsUtils.h"
+#include <stdlib.h>
+#include <string.h>
+
#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 */
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)
table->dir[segment][index] = hl->next;
else
prev->next = hl->next;
+ freeHashList(hl);
table->kcount--;
return hl->data;
}
}
index--;
}
- free(table->dir[segment]);
+ stgFree(table->dir[segment]);
segment--;
index = HSEGSIZE - 1;
}
- free(table);
+ stgFree(table);
}
/* -----------------------------------------------------------------------------