From 5f7f58ea8a72d2c68547a810dc70eb6c7ef95a64 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 16 Jun 2005 23:06:38 +0000 Subject: [PATCH] all-tests now pass without out of memory errors --- native/array.c | 8 ++++---- native/run.h | 5 +++++ native/string.c | 8 ++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/native/array.c b/native/array.c index bbf9a4cbdf..231dd54b4b 100644 --- a/native/array.c +++ b/native/array.c @@ -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) diff --git a/native/run.h b/native/run.h index 7ee81f22b9..1f4bec2319 100644 --- a/native/run.h +++ b/native/run.h @@ -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); diff --git a/native/string.c b/native/string.c index 2b075189e4..0947adcce2 100644 --- a/native/string.c +++ b/native/string.c @@ -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) -- 2.34.1