Revision
3807
Author
lsansonetti@apple.com
Date
2010-03-18 13:48:58 -0700 (Thu, 18 Mar 2010)

Log Message

revert r3806 because it breaks the specs and it also smells like a bad change

Modified Paths

Diff

Modified: MacRuby/trunk/bignum.c (3806 => 3807)


--- MacRuby/trunk/bignum.c	2010-03-18 16:25:18 UTC (rev 3806)
+++ MacRuby/trunk/bignum.c	2010-03-18 20:48:58 UTC (rev 3807)
@@ -105,9 +105,15 @@
 	    }
 	}
 	else {
-	    RBIGNUM(big)->as.heap.digits = NULL;
-	    GC_WB(&RBIGNUM(big)->as.heap.digits, ALLOC_N(BDIGIT, len));
-	    RBIGNUM_SET_LEN(big, len);
+	    if (RBIGNUM_LEN(big) == 0) {
+		GC_WB(&RBIGNUM(big)->as.heap.digits, ALLOC_N(BDIGIT, len));
+	    }
+	    else {
+		void *tmp = ruby_xrealloc(RBIGNUM(big)->as.heap.digits, sizeof(BDIGIT) * len);
+		if (tmp != RBIGNUM(big)->as.heap.digits) {
+		    GC_WB(&RBIGNUM(big)->as.heap.digits, tmp);
+		}
+	    }
 	}
     }
 }