projects
/
SXSI
/
TextCollection.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Debug swcsa
[SXSI/TextCollection.git]
/
swcsa
/
utils
/
hash.c
diff --git
a/swcsa/utils/hash.c
b/swcsa/utils/hash.c
index
a8aa4f7
..
5512920
100755
(executable)
--- a/
swcsa/utils/hash.c
+++ b/
swcsa/utils/hash.c
@@
-47,8
+47,12
@@
t_hash initialize_hash (unsigned long sizeVoc) {
unsigned long i;
h = (t_hash) malloc(sizeof(struct hashStr));
unsigned long i;
h = (t_hash) malloc(sizeof(struct hashStr));
- h->SIZE_HASH = (unsigned long) (OCUP_HASH * sizeVoc);
- h->SIZE_HASH = NearestPrime(h->SIZE_HASH);
+ unsigned long m = 6 * sizeVoc;
+ h->SIZE_HASH = sizeVoc;
+ do {
+ h->SIZE_HASH = NearestPrime(h->SIZE_HASH);
+ } while (h->SIZE_HASH >= m);
+
h->hash = (t_hashNode *) malloc(h->SIZE_HASH * sizeof(t_hashNode));
h->NumElem = 0;
h->hash = (t_hashNode *) malloc(h->SIZE_HASH * sizeof(t_hashNode));
h->NumElem = 0;
@@
-290,9
+294,7
@@
void insertElement (t_hash h, const unsigned char *aWord, register unsigned long
if(h->NumElem >= h->SIZE_HASH/2)
{
if(h->NumElem >= h->SIZE_HASH/2)
{
-
resize(h);
resize(h);
-
}
//h->hash[*addr].word = (unsigned char*) malloc((len+1) * sizeof(unsigned char));
getMemoryBlock(h->_memMgr,( byte **)&(h->hash[*addr].word),len+1);
}
//h->hash[*addr].word = (unsigned char*) malloc((len+1) * sizeof(unsigned char));
getMemoryBlock(h->_memMgr,( byte **)&(h->hash[*addr].word),len+1);