@@ -3315,7 +3315,7 @@ LONG SplitMerge(PHEAD WORD **Pointer, LONG number)
33153315{
33163316 GETBIDENTITY
33173317 SORTING * S = AT .SS ;
3318- WORD * * pp3 , * * pp1 , * * pp2 ;
3318+ WORD * * pp3 , * * pp1 , * * pp2 , * * pptop ;
33193319 LONG i , newleft , newright , split ;
33203320
33213321 if ( number < 2 ) return (number );
@@ -3331,6 +3331,7 @@ LONG SplitMerge(PHEAD WORD **Pointer, LONG number)
33313331 }
33323332 return (number );
33333333 }
3334+ pptop = Pointer + number ;
33343335 split = number /2 ;
33353336 newleft = SplitMerge (BHEAD Pointer ,split );
33363337 newright = SplitMerge (BHEAD Pointer + split ,number - split );
@@ -3354,12 +3355,13 @@ LONG SplitMerge(PHEAD WORD **Pointer, LONG number)
33543355 if ( AddCoef (BHEAD pp1 ,pp2 ) > 0 ) pp1 ++ ;
33553356 else newleft -- ;
33563357 }
3357- pp2 ++ ; newright -- ;
3358+ * pp2 ++ = 0 ; newright -- ;
33583359 }
33593360 else pp1 ++ ;
33603361 newleft += newright ;
33613362 if ( pp1 < pp2 ) {
33623363 while ( -- newright >= 0 ) * pp1 ++ = * pp2 ++ ;
3364+ while ( pp1 < pptop ) * pp1 ++ = 0 ;
33633365 }
33643366 return (newleft );
33653367 }
@@ -3371,8 +3373,9 @@ LONG SplitMerge(PHEAD WORD **Pointer, LONG number)
33713373 if ( AN .SplitScratch ) M_free (AN .SplitScratch ,"AN.SplitScratch" );
33723374 AN .SplitScratch = (WORD * * )Malloc1 (AN .SplitScratchSize * sizeof (WORD * ),"AN.SplitScratch" );
33733375 }
3376+
33743377 pp3 = AN .SplitScratch ; pp1 = Pointer ;
3375- for ( i = 0 ; i < newleft ; i ++ ) * pp3 ++ = * pp1 ++ ;
3378+ for ( i = 0 ; i < newleft ; i ++ ) { * pp3 ++ = * pp1 ++ ; }
33763379 AN .InScratch = newleft ;
33773380 pp1 = AN .SplitScratch ; pp2 = Pointer + split ; pp3 = Pointer ;
33783381/*
@@ -3396,27 +3399,31 @@ LONG SplitMerge(PHEAD WORD **Pointer, LONG number)
33963399
33973400 while ( newleft > 0 && newright > 0 ) {
33983401 if ( ( i = CompareTerms (BHEAD * pp1 ,* pp2 ,(WORD )0 ) ) < 0 ) {
3399- * pp3 ++ = * pp2 ++ ;
3402+ * pp3 ++ = * pp2 ;
3403+ * pp2 ++ = 0 ;
34003404 newright -- ;
34013405 }
34023406 else if ( i > 0 ) {
3403- * pp3 ++ = * pp1 ++ ;
3407+ * pp3 ++ = * pp1 ;
3408+ * pp1 ++ = 0 ;
34043409 newleft -- ;
34053410 }
34063411 else {
34073412 if ( S -> PolyWise ) { if ( AddPoly (BHEAD pp1 ,pp2 ) > 0 ) * pp3 ++ = * pp1 ; }
34083413 else { if ( AddCoef (BHEAD pp1 ,pp2 ) > 0 ) * pp3 ++ = * pp1 ; }
3409- pp1 ++ ; pp2 ++ ; newleft -- ; newright -- ;
3414+ * pp1 ++ = 0 ; * pp2 ++ = 0 ; newleft -- ; newright -- ;
34103415 }
34113416 }
3412- for ( i = 0 ; i < newleft ; i ++ ) * pp3 ++ = * pp1 ++ ;
3417+ for ( i = 0 ; i < newleft ; i ++ ) { * pp3 ++ = * pp1 ; * pp1 ++ = 0 ; }
34133418 if ( pp3 == pp2 ) {
34143419 pp3 += newright ;
34153420 } else {
3416- for ( i = 0 ; i < newright ; i ++ ) * pp3 ++ = * pp2 ++ ;
3421+ for ( i = 0 ; i < newright ; i ++ ) { * pp3 ++ = * pp2 ++ ; }
34173422 }
3423+ newleft = pp3 - Pointer ;
3424+ while ( pp3 < pptop ) * pp3 ++ = 0 ;
34183425 AN .InScratch = 0 ;
3419- return (pp3 - Pointer );
3426+ return (newleft );
34203427}
34213428
34223429#else
@@ -3545,7 +3552,7 @@ VOID GarbHand(VOID)
35453552*/
35463553#ifdef TESTGARB
35473554 MLOCK (ErrorMessageLock );
3548- MesPrint ("in: S->sFill = %x , S->sTop2 = %x " ,S -> sFill ,S -> sTop2 );
3555+ MesPrint ("in: S->sFill = %l , S->sTop2 = %l " ,S -> sFill - S -> sBuffer ,S -> sTop2 - S -> sBuffer );
35493556#endif
35503557 Point = S -> sPointer ;
35513558 k = S -> sTerms ;
@@ -3558,7 +3565,7 @@ VOID GarbHand(VOID)
35583565 if ( ( s2 = * Point ++ ) != 0 ) { total += * s2 ; }
35593566 }
35603567#ifdef TESTGARB
3561- MesPrint ("total = %l, nterms = %l" ,2 * total ,AN .InScratch );
3568+ MesPrint ("total = %l, nterms = %l" ,total ,AN .InScratch );
35623569 MUNLOCK (ErrorMessageLock );
35633570#endif
35643571/*
@@ -3618,7 +3625,7 @@ VOID GarbHand(VOID)
36183625 S -> sFill = s2 ;
36193626#ifdef TESTGARB
36203627 MLOCK (ErrorMessageLock );
3621- MesPrint ("out: S->sFill = %x , S->sTop2 = %x " ,S -> sFill ,S -> sTop2 );
3628+ MesPrint ("out: S->sFill = %l , S->sTop2 = %l " ,S -> sFill - S -> sBuffer ,S -> sTop2 - S -> sBuffer );
36223629 if ( S -> sFill >= S -> sTop2 ) {
36233630 MesPrint ("We are in deep trouble" );
36243631 }
0 commit comments