From e7b01f64d000c1980694712662805e8f4aad272b Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sun, 26 Apr 2009 10:50:56 -0500 Subject: [PATCH] don't add minimums, compare them for memory overflows. --- C/heapgc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/C/heapgc.c b/C/heapgc.c index 499d26fb1..a937a517e 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -3957,7 +3957,7 @@ call_gc(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop) LeaveGCMode(); if (gc_margin < 2*CalculateStackGap()) gc_margin = 2*CalculateStackGap(); - return Yap_growstack(gc_margin*sizeof(CELL)); + return Yap_growstack(gc_margin); } /* * debug for(save_total=1; save_total<=N; ++save_total) @@ -4003,8 +4003,12 @@ int Yap_gcl(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop) { int res; + UInt min = CalculateStackGap()*sizeof(CELL); + Yap_PrologMode |= GCMode; - res = call_gc(gc_lim+CalculateStackGap()*sizeof(CELL), predarity, current_env, nextop); + if (gc_lim < min) + gc_lim = min; + res = call_gc(gc_lim, predarity, current_env, nextop); LeaveGCMode(); return res; }