]> gitweb.factorcode.org Git - factor.git/commitdiff
all-tests now pass without out of memory errors 0.75 release-0-75
authorSlava Pestov <slava@factorcode.org>
Thu, 16 Jun 2005 23:06:38 +0000 (23:06 +0000)
committerSlava Pestov <slava@factorcode.org>
Thu, 16 Jun 2005 23:06:38 +0000 (23:06 +0000)
native/array.c
native/run.h
native/string.c

index bbf9a4cbdf04e1f2dddc629babdc3c5e77e70de8..231dd54b4b007658dd8a1d1d40cc3e326e44dfe3 100644 (file)
@@ -71,11 +71,11 @@ F_ARRAY* resize_array(F_ARRAY* array, CELL capacity, CELL fill)
 
 void primitive_resize_array(void)
 {
-       F_ARRAY* array; CELL capacity;
-       maybe_gc(0);
+       F_ARRAY* array;
+       CELL capacity = to_fixnum(dpeek2());
+       maybe_gc(array_size(capacity));
        array = untag_array_fast(dpop());
-       capacity = to_fixnum(dpop());
-       dpush(tag_object(resize_array(array,capacity,F)));
+       drepl(tag_object(resize_array(array,capacity,F)));
 }
 
 void fixup_array(F_ARRAY* array)
index 7ee81f22b966d4bbe2376cd063cb8fbd0362a8da..1f4bec23194e0aa39d9156e0dd0dd0a797f44e31 100644 (file)
@@ -58,6 +58,11 @@ INLINE CELL dpeek(void)
        return get(ds);
 }
 
+INLINE CELL dpeek2(void)
+{
+       return get(ds - CELLS);
+}
+
 INLINE CELL cpop(void)
 {
        CELL value = get(cs);
index 2b075189e4b6e046c31eb8dee73ace1942b18081..0947adcce2943307762dbed6160ca76c128311cb 100644 (file)
@@ -66,11 +66,11 @@ F_STRING* resize_string(F_STRING* string, F_FIXNUM capacity, u16 fill)
 
 void primitive_resize_string(void)
 {
-       F_STRING* string; CELL capacity;
-       maybe_gc(0);
+       F_STRING* string;
+       CELL capacity = to_fixnum(dpeek2());
+       maybe_gc(string_size(capacity));
        string = untag_string_fast(dpop());
-       capacity = to_fixnum(dpop());
-       dpush(tag_object(resize_string(string,capacity,F)));
+       drepl(tag_object(resize_string(string,capacity,F)));
 }
 
 F_STRING *memory_to_string(const BYTE* string, CELL length)