fix overflow of attributed variables in copy_term

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1126 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2004-09-07 20:20:12 +00:00
parent 2068026152
commit 040280ea73
3 changed files with 37 additions and 31 deletions

View File

@ -366,6 +366,7 @@ BuildNewAttVar(Term t, Int i, Term tatt)
attv->NS = Yap_UpdateTimedVar(AttsMutableList, (CELL)&(attv->Done)); attv->NS = Yap_UpdateTimedVar(AttsMutableList, (CELL)&(attv->Done));
Bind((CELL *)t,(CELL)attv); Bind((CELL *)t,(CELL)attv);
Yap_UpdateTimedVar(DelayedVars,(CELL)(attv->Atts+2*j)); Yap_UpdateTimedVar(DelayedVars,(CELL)(attv->Atts+2*j));
/* avoid trouble in gc */
/* if i < 0 then we have the list of arguments */ /* if i < 0 then we have the list of arguments */
if (i < 0) { if (i < 0) {
Int j = 0; Int j = 0;

View File

@ -254,8 +254,8 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
/* restore our nice, friendly, term to its original state */ /* restore our nice, friendly, term to its original state */
HB = HB0; HB = HB0;
clean_dirty_tr(TR0); reset_trail(TR0);
return(0); return 0;
overflow: overflow:
/* oops, we're in trouble */ /* oops, we're in trouble */
@ -272,8 +272,8 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
*pt0 = (CELL)to_visit[3]; *pt0 = (CELL)to_visit[3];
} }
#endif #endif
clean_dirty_tr(TR0); reset_trail(TR0);
return(-1); return -1;
heap_overflow: heap_overflow:
/* oops, we're in trouble */ /* oops, we're in trouble */
@ -291,7 +291,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
} }
#endif #endif
clean_dirty_tr(TR0); clean_dirty_tr(TR0);
return(-2); return -2;
} }
static Term static Term

View File

@ -369,14 +369,8 @@ Unification Routines
EXTERN Int STD_PROTO(Yap_unify,(Term,Term)); EXTERN Int STD_PROTO(Yap_unify,(Term,Term));
EXTERN inline EXTERN inline void
Int Yap_unify(Term t0, Term t1) reset_trail(tr_fr_ptr TR0) {
{
tr_fr_ptr TR0 = TR;
if (Yap_IUnify(t0,t1)) {
return(TRUE);
} else {
while(TR != TR0) { while(TR != TR0) {
CELL d1; CELL d1;
--TR; --TR;
@ -401,7 +395,18 @@ Int Yap_unify(Term t0, Term t1)
} }
#endif #endif
} }
return(FALSE); }
EXTERN inline
Int Yap_unify(Term t0, Term t1)
{
tr_fr_ptr TR0 = TR;
if (Yap_IUnify(t0,t1)) {
return TRUE;
} else {
reset_trail(TR0);
return FALSE;
} }
} }