summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-13 04:15:51 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-13 04:15:51 +0000
commit1454c9812becc4d64bb319cb76a2563c69a2ec5e (patch)
tree15cbc5598eff26f869964a164761ae822e3935d9
parent465eec7158652dea2823f919eb3f4b0ed01e9ff3 (diff)
merge revision(s) 15429, 15471:
* gc.c (rb_newobj): prohibit call of rb_newobj() during gc. Submitted by Sylvain Joyeux [ruby-core:12099]. * ext/dl/ptr.c: do not use LONG2NUM() inside dlptr_free(). Slightly modified fix bassed on a patch by Sylvain Joyeux [ruby-core:12099] [ ruby-bugs-11859 ] [ ruby-bugs-11882 ] [ ruby-patches-13151 ]. * ext/dl/ptr.c (dlmem_each_i): typo fixed. a patch from IKOMA Yoshiki <ikoma@mb.i-chubu.ne.jp> in [ruby-dev:33776]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@17140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog15
-rw-r--r--ext/dl/ptr.c36
-rw-r--r--gc.c3
-rw-r--r--version.h2
4 files changed, 32 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index cef2c66..18665b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+Fri Jun 13 13:14:31 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/dl/ptr.c (dlmem_each_i): typo fixed. a patch from IKOMA
+ Yoshiki <ikoma@mb.i-chubu.ne.jp> in [ruby-dev:33776].
+
+Fri Jun 13 13:13:23 2008 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
+
+ * gc.c (rb_newobj): prohibit call of rb_newobj() during gc.
+ Submitted by Sylvain Joyeux [ruby-core:12099].
+
+ * ext/dl/ptr.c: do not use LONG2NUM() inside dlptr_free().
+ Slightly modified fix bassed on a patch by Sylvain Joyeux
+ [ruby-core:12099] [ ruby-bugs-11859 ] [ ruby-bugs-11882 ]
+ [ ruby-patches-13151 ].
+
Fri Jun 13 12:10:13 2008 NARUSE, Yui <naruse@ruby-lang.org>
* lib/benchmark.rb (Job::Benchmark#item): fix typo.
diff --git a/ext/dl/ptr.c b/ext/dl/ptr.c
index 5112151..7e3d354 100644
--- a/ext/dl/ptr.c
+++ b/ext/dl/ptr.c
@@ -4,30 +4,22 @@
#include <ruby.h>
#include <ctype.h>
-#include <version.h> /* for ruby version code */
+#include "st.h"
#include "dl.h"
VALUE rb_cDLPtrData;
VALUE rb_mDLMemorySpace;
-static VALUE DLMemoryTable;
+static st_table* st_memory_table;
#ifndef T_SYMBOL
# define T_SYMBOL T_FIXNUM
#endif
-#if RUBY_VERSION_CODE < 171
-static VALUE
-rb_hash_delete(VALUE hash, VALUE key)
-{
- return rb_funcall(hash, rb_intern("delete"), 1, key);
-}
-#endif
-
static void
rb_dlmem_delete(void *ptr)
{
rb_secure(4);
- rb_hash_delete(DLMemoryTable, DLLONG2NUM(ptr));
+ st_delete(st_memory_table, (st_data_t*)&ptr, NULL);
}
static void
@@ -37,7 +29,7 @@ rb_dlmem_aset(void *ptr, VALUE obj)
rb_dlmem_delete(ptr);
}
else{
- rb_hash_aset(DLMemoryTable, DLLONG2NUM(ptr), DLLONG2NUM(obj));
+ st_insert(st_memory_table, (st_data_t)ptr, (st_data_t)obj);
}
}
@@ -46,8 +38,8 @@ rb_dlmem_aref(void *ptr)
{
VALUE val;
- val = rb_hash_aref(DLMemoryTable, DLLONG2NUM(ptr));
- return val == Qnil ? Qnil : (VALUE)DLNUM2LONG(val);
+ if(!st_lookup(st_memory_table, (st_data_t)ptr, &val)) return Qnil;
+ return val == Qundef ? Qnil : val;
}
void
@@ -1010,20 +1002,18 @@ rb_dlptr_size(int argc, VALUE argv[], VALUE self)
}
}
-static VALUE
-dlmem_each_i(VALUE assoc, void *data)
+static int
+dlmem_each_i(void* key, VALUE value, void* arg)
{
- VALUE key, val;
- key = rb_ary_entry(assoc, 0);
- val = rb_ary_entry(assoc, 1);
- rb_yield(rb_assoc_new(key,(VALUE)DLNUM2LONG(val)));
+ VALUE vkey = DLLONG2NUM(key);
+ rb_yield(rb_assoc_new(vkey, value));
return Qnil;
}
VALUE
rb_dlmem_each(VALUE self)
{
- rb_iterate(rb_each, DLMemoryTable, dlmem_each_i, 0);
+ st_foreach(st_memory_table, dlmem_each_i, 0);
return Qnil;
}
@@ -1062,7 +1052,7 @@ Init_dlptr()
rb_define_method(rb_cDLPtrData, "size=", rb_dlptr_size, -1);
rb_mDLMemorySpace = rb_define_module_under(rb_mDL, "MemorySpace");
- DLMemoryTable = rb_hash_new();
- rb_define_const(rb_mDLMemorySpace, "MemoryTable", DLMemoryTable);
+ st_memory_table = st_init_numtable();
+ rb_define_const(rb_mDLMemorySpace, "MemoryTable", Qnil); /* historical */
rb_define_module_function(rb_mDLMemorySpace, "each", rb_dlmem_each, 0);
}
diff --git a/gc.c b/gc.c
index a048049..bc3ef5a 100644
--- a/gc.c
+++ b/gc.c
@@ -378,6 +378,9 @@ rb_newobj()
{
VALUE obj;
+ if (during_gc)
+ rb_bug("object allocation during garbage collection phase");
+
if (!freelist) garbage_collect();
obj = (VALUE)freelist;
diff --git a/version.h b/version.h
index bd2827b..5811945 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2008-06-13"
#define RUBY_VERSION_CODE 186
#define RUBY_RELEASE_CODE 20080613
-#define RUBY_PATCHLEVEL 174
+#define RUBY_PATCHLEVEL 175
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8