Skip to content

Commit

Permalink
merge revision(s) 15429, 15471:
Browse files Browse the repository at this point in the history
	* 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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_6@17140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
shyouhei committed Jun 13, 2008
1 parent 62b4628 commit 0d04ec4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 24 deletions.
15 changes: 15 additions & 0 deletions 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.
Expand Down
36 changes: 13 additions & 23 deletions ext/dl/ptr.c
Expand Up @@ -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
Expand All @@ -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);
}
}

Expand All @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
3 changes: 3 additions & 0 deletions gc.c
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion version.h
Expand Up @@ -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
Expand Down

0 comments on commit 0d04ec4

Please sign in to comment.