mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* gc.c (rb_mark_set): new function to mark keys.
* marshal.c (struct dump_arg, struct load_arg): added wrappers to mark data and compat_tbl entries. [ruby-dev:31870] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
71341b814a
commit
b416cc6f3f
4 changed files with 38 additions and 9 deletions
|
@ -1,7 +1,9 @@
|
|||
Thu Sep 27 04:12:01 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Thu Sep 27 04:40:47 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* gc.c (rb_mark_set): new function to mark keys.
|
||||
|
||||
* marshal.c (struct dump_arg, struct load_arg): added wrappers to mark
|
||||
compat_tbl entries. [ruby-dev:31870]
|
||||
data and compat_tbl entries. [ruby-dev:31870]
|
||||
|
||||
Thu Sep 27 03:17:41 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
|
|
20
gc.c
20
gc.c
|
@ -783,6 +783,26 @@ rb_mark_tbl(st_table *tbl)
|
|||
mark_tbl(tbl, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
mark_key(VALUE key, VALUE value, int lev)
|
||||
{
|
||||
gc_mark(key, lev);
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
static void
|
||||
mark_set(st_table *tbl, int lev)
|
||||
{
|
||||
if (!tbl) return;
|
||||
st_foreach(tbl, mark_key, lev);
|
||||
}
|
||||
|
||||
void
|
||||
rb_mark_set(st_table *tbl)
|
||||
{
|
||||
mark_set(tbl, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
mark_keyvalue(VALUE key, VALUE value, int lev)
|
||||
{
|
||||
|
|
|
@ -307,6 +307,7 @@ int ruby_stack_length(VALUE**);
|
|||
char *rb_source_filename(const char*);
|
||||
void rb_gc_mark_locations(VALUE*, VALUE*);
|
||||
void rb_mark_tbl(struct st_table*);
|
||||
void rb_mark_set(struct st_table*);
|
||||
void rb_mark_hash(struct st_table*);
|
||||
void rb_gc_mark_maybe(VALUE);
|
||||
void rb_gc_mark(VALUE);
|
||||
|
|
20
marshal.c
20
marshal.c
|
@ -89,8 +89,6 @@ typedef struct {
|
|||
VALUE (*loader)(VALUE, VALUE);
|
||||
} marshal_compat_t;
|
||||
|
||||
#define make_compat_tbl_wrapper(tbl) Data_Wrap_Struct(rb_cData, rb_mark_tbl, 0, tbl)
|
||||
|
||||
static st_table *compat_allocator_tbl;
|
||||
static VALUE compat_allocator_tbl_wrapper;
|
||||
|
||||
|
@ -138,7 +136,7 @@ struct dump_arg {
|
|||
st_table *data;
|
||||
int taint;
|
||||
st_table *compat_tbl;
|
||||
VALUE compat_tbl_wrapper;
|
||||
VALUE wrapper;
|
||||
};
|
||||
|
||||
struct dump_call_arg {
|
||||
|
@ -147,6 +145,14 @@ struct dump_call_arg {
|
|||
int limit;
|
||||
};
|
||||
|
||||
static void
|
||||
mark_dump_arg(void *ptr)
|
||||
{
|
||||
struct dump_arg *p = ptr;
|
||||
rb_mark_set(p->data);
|
||||
rb_mark_hash(p->compat_tbl);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
class2path(VALUE klass)
|
||||
{
|
||||
|
@ -722,8 +728,8 @@ dump_ensure(struct dump_arg *arg)
|
|||
st_free_table(arg->symbols);
|
||||
st_free_table(arg->data);
|
||||
st_free_table(arg->compat_tbl);
|
||||
DATA_PTR(arg->compat_tbl_wrapper) = 0;
|
||||
arg->compat_tbl_wrapper = 0;
|
||||
DATA_PTR(arg->wrapper) = 0;
|
||||
arg->wrapper = 0;
|
||||
if (arg->taint) {
|
||||
OBJ_TAINT(arg->str);
|
||||
}
|
||||
|
@ -797,7 +803,7 @@ marshal_dump(int argc, VALUE *argv)
|
|||
arg.data = st_init_numtable();
|
||||
arg.taint = Qfalse;
|
||||
arg.compat_tbl = st_init_numtable();
|
||||
arg.compat_tbl_wrapper = make_compat_tbl_wrapper(arg.compat_tbl);
|
||||
arg.wrapper = Data_Wrap_Struct(rb_cData, mark_dump_arg, 0, &arg);
|
||||
c_arg.obj = obj;
|
||||
c_arg.arg = &arg;
|
||||
c_arg.limit = limit;
|
||||
|
@ -1499,7 +1505,7 @@ marshal_load(int argc, VALUE *argv)
|
|||
arg.src = port;
|
||||
arg.offset = 0;
|
||||
arg.compat_tbl = st_init_numtable();
|
||||
arg.compat_tbl_wrapper = make_compat_tbl_wrapper(arg.compat_tbl);
|
||||
arg.compat_tbl_wrapper = Data_Wrap_Struct(rb_cData, rb_mark_tbl, 0, arg.compat_tbl);
|
||||
|
||||
major = r_byte(&arg);
|
||||
minor = r_byte(&arg);
|
||||
|
|
Loading…
Reference in a new issue