From 7881363731eb4695c745b49ad67652ae8062f995 Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 6 Sep 2002 08:59:41 +0000 Subject: [PATCH] * gc.c (ruby_xmalloc): remove MALLOC_LIMIT to avoid frequent garabage collection. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ToDo | 1 - file.c | 2 +- gc.c | 20 +------------------- marshal.c | 2 +- missing/vsnprintf.c | 7 +++++-- 6 files changed, 13 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 39ccfcc6d8..f4e56ab3bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,11 @@ Fri Sep 6 12:11:22 2002 Minero Aoki * parse.y (rb_gc_mark_parser): should mark ALL global variables defined in parse.y. +Fri Sep 6 01:15:23 2002 Yukihiro Matsumoto + + * gc.c (ruby_xmalloc): remove MALLOC_LIMIT to avoid frequent + garabage collection. + Fri Sep 6 11:47:37 2002 Minero Aoki * parse.y (rb_gc_mark_parser): should mark global variables diff --git a/ToDo b/ToDo index 9bd0207601..fa7f32daed 100644 --- a/ToDo +++ b/ToDo @@ -106,7 +106,6 @@ Standard Libraries * deprecate Array#indexes, and Array#indices. * require "1.6" etc. by /usr/lib/ruby/1.6/1.6.rb ;-) * save both "feature names" and "normalized path" in $" -* allow marshaling of extend'ed object. Extension Libraries diff --git a/file.c b/file.c index a32d962df1..8a91e20ad9 100644 --- a/file.c +++ b/file.c @@ -2372,7 +2372,7 @@ path_check_1(path) && (!p || !(st.st_mode & S_ISVTX)) #endif ) { - rb_warn("Insecure world writable dir %s , mode 0%o", p0, st.st_mode); + rb_warn("Insecure world writable dir %s, mode 0%o", p0, st.st_mode); if (p) *p = '/'; return 0; } diff --git a/gc.c b/gc.c index 84842b3d66..3ecac66aba 100644 --- a/gc.c +++ b/gc.c @@ -53,16 +53,6 @@ void *alloca (); #endif static void run_final(); - -#ifndef GC_MALLOC_LIMIT -#if defined(MSDOS) || defined(__human68k__) -#define GC_MALLOC_LIMIT 200000 -#else -#define GC_MALLOC_LIMIT 8000000 -#endif -#endif - -static unsigned long malloc_memories = 0; static VALUE nomem_error; void @@ -88,11 +78,7 @@ ruby_xmalloc(size) rb_raise(rb_eNoMemError, "negative allocation size (or too big)"); } if (size == 0) size = 1; - malloc_memories += size; - if (malloc_memories > GC_MALLOC_LIMIT) { - rb_gc(); - } RUBY_CRITICAL(mem = malloc(size)); if (!mem) { rb_gc(); @@ -129,7 +115,6 @@ ruby_xrealloc(ptr, size) } if (!ptr) return xmalloc(size); if (size == 0) size = 1; - malloc_memories += size; RUBY_CRITICAL(mem = realloc(ptr, size)); if (!mem) { rb_gc(); @@ -1131,15 +1116,12 @@ rb_gc() SET_STACK_END; if (dont_gc || during_gc) { - if (!freelist || malloc_memories > GC_MALLOC_LIMIT) { - malloc_memories = 0; + if (!freelist) { add_heap(); } return; } - malloc_memories = 0; - if (during_gc) return; during_gc++; diff --git a/marshal.c b/marshal.c index e6672d229c..e52508db25 100644 --- a/marshal.c +++ b/marshal.c @@ -114,7 +114,7 @@ w_bytes(s, n, arg) fwrite(s, 1, n, arg->fp); } else { - rb_str_cat(arg->str, s, n); + rb_str_buf_cat(arg->str, s, n); } } diff --git a/missing/vsnprintf.c b/missing/vsnprintf.c index b21261d7df..266290a139 100644 --- a/missing/vsnprintf.c +++ b/missing/vsnprintf.c @@ -1018,8 +1018,11 @@ cvt(value, ndigits, flags, sign, decpt, ch, length) if (value < 0) { value = -value; *sign = '-'; - } else - *sign = '\000'; + } else if (value == 0.0 && 1.0/value < 0) { + *sign = '-'; + } else { + *sign = '\000'; + } digits = BSD__dtoa(value, mode, ndigits, decpt, &dsgn, &rve); if (flags & ALT) { /* Print trailing zeros */ bp = digits + ndigits;