diff --git a/C/adtdefs.c b/C/adtdefs.c index 60ec94df6..108c66a3f 100644 --- a/C/adtdefs.c +++ b/C/adtdefs.c @@ -148,7 +148,7 @@ LookupAtom(char *atom) /* compute hash */ p = (unsigned char *)atom; - HashFunction(p, hash); + hash = HashFunction(p) % MaxHash; WRITE_LOCK(HashChain[hash].AERWLock); a = HashChain[hash].Entry; /* search atom in chain */ @@ -196,7 +196,7 @@ Yap_LookupAtomWithAddress(char *atom, AtomEntry *ae) /* compute hash */ p = (unsigned char *)atom; - HashFunction(p, hash); + hash = HashFunction(p) % MaxHash; /* ask for a WRITE lock because it is highly unlikely we shall find anything */ WRITE_LOCK(HashChain[hash].AERWLock); a = HashChain[hash].Entry; @@ -226,7 +226,7 @@ Yap_ReleaseAtom(Atom atom) /* compute hash */ p = (unsigned char *)name; - HashFunction(p, hash); + hash = HashFunction(p) % MaxHash; WRITE_LOCK(HashChain[hash].AERWLock); if (HashChain[hash].Entry == atom) { HashChain[hash].Entry = ap->NextOfAE; diff --git a/C/index.c b/C/index.c index 4c40f423c..0744ec224 100644 --- a/C/index.c +++ b/C/index.c @@ -4470,7 +4470,7 @@ kill_block(path_stack_entry *sp, PredEntry *ap) } static path_stack_entry * -kill_clause(yamop *ipc, path_stack_entry *sp, PredEntry *ap) +kill_clause(yamop *ipc, yamop *bg, yamop *lt, path_stack_entry *sp, PredEntry *ap) { LogUpdIndex *blk; yamop *start; @@ -4498,11 +4498,11 @@ kill_clause(yamop *ipc, path_stack_entry *sp, PredEntry *ap) case _retry: case _try_clause: /* kill block and replace by this single clause */ - if (codep != ipc) { + if (!IN_BETWEEN(bg, codep->u.ld.d, lt)) { path_stack_entry *nsp = sp; while ((--nsp)->flag != block_entry); - *sp->u.cle.entry_code = ipc->u.ld.d; + *sp->u.cle.entry_code = codep->u.ld.d; Yap_kill_iblock(sp->u.cle.block, nsp->u.cle.block, ap); return sp; } else { @@ -5472,7 +5472,7 @@ remove_from_index(PredEntry *ap, path_stack_entry *sp, ClauseDef *cls, yamop *bg have to expand the index. */ if (IN_BETWEEN(bg,ipc->u.ld.d,lt)) { - sp = kill_clause(ipc, sp, ap); + sp = kill_clause(ipc, bg, lt, sp, ap); ipc = pop_path(&sp, cls, ap); } else { /* just go to next instruction */ @@ -5486,7 +5486,7 @@ remove_from_index(PredEntry *ap, path_stack_entry *sp, ClauseDef *cls, yamop *bg ipc = NEXTOP(ipc, ld); case _trust: if (IN_BETWEEN(bg,ipc->u.ld.d,lt)) { - sp = kill_clause(ipc, sp, ap); + sp = kill_clause(ipc, bg, lt, sp, ap); } ipc = pop_path(&sp, cls, ap); break; diff --git a/C/parser.c b/C/parser.c index 1502a11d6..2e0ba661e 100644 --- a/C/parser.c +++ b/C/parser.c @@ -121,10 +121,10 @@ Yap_LookupVar(char *var) /* lookup variable in variables table */ if (var[0] != '_' || var[1] != '\0') { VarEntry **op = &Yap_VarTable; unsigned char *vp = (unsigned char *)var; - CELL hv; + UInt hv; p = Yap_VarTable; - HashFunction(vp, hv); + hv = HashFunction(vp) % MaxHash; while (p != NULL) { CELL hpv = p->hv; if (hv == hpv) { diff --git a/H/yapio.h b/H/yapio.h index 9374e42b5..427458014 100644 --- a/H/yapio.h +++ b/H/yapio.h @@ -323,7 +323,13 @@ extern int Yap_Portray_delays; #endif #endif -#define HashFunction(CHP,OUT) { (OUT)=0; while(*(CHP) != '\0') (OUT) += *(CHP)++; (OUT) %= MaxHash; } +EXTERN inline UInt +HashFunction(char *CHP) +{ + UInt OUT=0; + while(*CHP != '\0') OUT += (UInt)(*CHP++); + return OUT; +} #define FAIL_ON_PARSER_ERROR 0 #define QUIET_ON_PARSER_ERROR 1