From 34ea2e6905e86289e4c2b6980fe8cbe9eb189d6b Mon Sep 17 00:00:00 2001 From: vsc Date: Fri, 18 Jun 2004 16:35:18 +0000 Subject: [PATCH] fix array handling of DBRefs git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1083 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/agc.c | 2 +- C/arrays.c | 23 ++++++++++++++++++----- C/tracer.c | 4 ---- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/C/agc.c b/C/agc.c index 98df42468..cc02d75c2 100644 --- a/C/agc.c +++ b/C/agc.c @@ -365,7 +365,7 @@ atom_gc(void) agc_calls++; agc_collected = 0; if (gc_trace) { - fprintf(Yap_stderr, "[agc]\n"); + fprintf(Yap_stderr, "AGC]\n"); } else if (gc_verbose) { fprintf(Yap_stderr, "[AGC] Start of atom garbage collection %d:\n", agc_calls); } diff --git a/C/arrays.c b/C/arrays.c index 8449296ff..a13ff6235 100644 --- a/C/arrays.c +++ b/C/arrays.c @@ -16,8 +16,7 @@ *************************************************************************/ #include "Yap.h" -#include "Yatom.h" -#include "Heap.h" +#include "clause.h" #include "eval.h" #include "heapgc.h" #if HAVE_ERRNO_H @@ -1542,6 +1541,7 @@ p_assign_static(void) { Term t0 = ptr->ValueOfVE.dbrefs[indx]; + DBRef p = DBRefOfTerm(t3); if (!IsDBRefTerm(t3)) { WRITE_UNLOCK(ptr->ArRWLock); @@ -1549,9 +1549,22 @@ p_assign_static(void) return (FALSE); } ptr->ValueOfVE.dbrefs[indx]= t3; - if (t0 != 0L) - DBRefOfTerm(t0)->NOfRefsTo--; - DBRefOfTerm(t3)->NOfRefsTo++; + if (t0 != 0L) { + DBRef ptr = DBRefOfTerm(t0); + if (ptr->Flags & LogUpdMask) { + LogUpdClause *lup = (LogUpdClause *)ptr; + lup->ClRefCount--; + } else { + ptr->NOfRefsTo--; + } + } + + if (p->Flags & LogUpdMask) { + LogUpdClause *lup = (LogUpdClause *)p; + lup->ClRefCount++; + } else { + p->NOfRefsTo++; + } } break; diff --git a/C/tracer.c b/C/tracer.c index 3c308efa4..fa3fb0933 100644 --- a/C/tracer.c +++ b/C/tracer.c @@ -106,13 +106,9 @@ check_trail_consistency(void) { */ -int vsc_xstop = FALSE; - CELL old_value = 0L, old_value2 = 0L; -/* void jmp_deb(int i) {if (i) printf("Here we go\n"); else jmp_deb(0);} -*/ void low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)