From ef80f1df70b211a710a5d87efcc2d20cae9debc8 Mon Sep 17 00:00:00 2001 From: vsc Date: Thu, 18 May 2006 13:07:48 +0000 Subject: [PATCH] fix growglobal to handle the USE_MALLOC case correctly. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1634 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/grow.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/C/grow.c b/C/grow.c index 697746830..437f77640 100644 --- a/C/grow.c +++ b/C/grow.c @@ -262,11 +262,19 @@ MoveGlobalOnly(void) * cpcellsd(To,From,NOfCells) - copy the cells downwards - in * absmi.asm */ +#if USE_SYSTEM_MALLOC +#if HAVE_MEMMOVE + cpcellsd(H0, (CELL *)((char *)OldH0+DelayDiff), OldH - OldH0); +#else + cpcellsd(H, (CELL *)((char *)OldH+DelayDiff), OldH - OldH0); +#endif +#else #if HAVE_MEMMOVE cpcellsd(H0, OldH0, OldH - OldH0); #else cpcellsd(H, OldH, OldH - OldH0); #endif +#endif } static void @@ -673,6 +681,12 @@ static_growglobal(long size, CELL **ptr) } ASP -= 256; YAPEnterCriticalSection(); +#if USE_SYSTEM_MALLOC + /* we always run the risk of shifting memory */ + size0 = Yap_GlobalBase-old_GlobalBase; + DelayDiff = size0; + TrDiff = LDiff = GDiff = size+size0; +#else if (minimal_request) { DelayDiff = size-size0; TrDiff = LDiff = GDiff = size; @@ -680,14 +694,15 @@ static_growglobal(long size, CELL **ptr) TrDiff = LDiff = GDiff = size; DelayDiff = 0; } +#endif XDiff = HDiff = 0; Yap_GlobalBase = old_GlobalBase; SetHeapRegs(); MoveLocalAndTrail(); + MoveGlobalOnly(); if (minimal_request) { MoveDelays(); } - MoveGlobalOnly(); AdjustStacksAndTrail(); AdjustRegs(MaxTemps); if (ptr)