* class.c (rb_mod_init_copy): fix memory leak of Class#dup.
[ruby-dev:39687] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
85ca612b13
commit
4a761c3209
@ -1,3 +1,8 @@
|
|||||||
|
Sat Nov 14 21:54:46 2009 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* class.c (rb_mod_init_copy): fix memory leak of Class#dup.
|
||||||
|
[ruby-dev:39687]
|
||||||
|
|
||||||
Sat Nov 14 17:09:39 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Nov 14 17:09:39 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* configure.in (--with-opt-dir): ignore and suppress a warning.
|
* configure.in (--with-opt-dir): ignore and suppress a warning.
|
||||||
|
8
class.c
8
class.c
@ -151,6 +151,9 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
|
|||||||
if (RCLASS_IV_TBL(orig)) {
|
if (RCLASS_IV_TBL(orig)) {
|
||||||
ID id;
|
ID id;
|
||||||
|
|
||||||
|
if (RCLASS_IV_TBL(clone)) {
|
||||||
|
st_free_table(RCLASS_IV_TBL(clone));
|
||||||
|
}
|
||||||
RCLASS_IV_TBL(clone) = st_copy(RCLASS_IV_TBL(orig));
|
RCLASS_IV_TBL(clone) = st_copy(RCLASS_IV_TBL(orig));
|
||||||
CONST_ID(id, "__classpath__");
|
CONST_ID(id, "__classpath__");
|
||||||
st_delete(RCLASS_IV_TBL(clone), (st_data_t*)&id, 0);
|
st_delete(RCLASS_IV_TBL(clone), (st_data_t*)&id, 0);
|
||||||
@ -159,6 +162,11 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
|
|||||||
}
|
}
|
||||||
if (RCLASS_M_TBL(orig)) {
|
if (RCLASS_M_TBL(orig)) {
|
||||||
struct clone_method_data data;
|
struct clone_method_data data;
|
||||||
|
|
||||||
|
if (RCLASS_M_TBL(clone)) {
|
||||||
|
extern void rb_free_m_table(st_table *tbl);
|
||||||
|
rb_free_m_table(RCLASS_M_TBL(clone));
|
||||||
|
}
|
||||||
data.tbl = RCLASS_M_TBL(clone) = st_init_numtable();
|
data.tbl = RCLASS_M_TBL(clone) = st_init_numtable();
|
||||||
data.klass = clone;
|
data.klass = clone;
|
||||||
st_foreach(RCLASS_M_TBL(orig), clone_method,
|
st_foreach(RCLASS_M_TBL(orig), clone_method,
|
||||||
|
6
gc.c
6
gc.c
@ -1459,8 +1459,8 @@ free_method_entry_i(ID key, rb_method_entry_t *me, st_data_t data)
|
|||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
free_m_table(st_table *tbl)
|
rb_free_m_table(st_table *tbl)
|
||||||
{
|
{
|
||||||
st_foreach(tbl, free_method_entry_i, 0);
|
st_foreach(tbl, free_method_entry_i, 0);
|
||||||
st_free_table(tbl);
|
st_free_table(tbl);
|
||||||
@ -1988,7 +1988,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
|
|||||||
case T_MODULE:
|
case T_MODULE:
|
||||||
case T_CLASS:
|
case T_CLASS:
|
||||||
rb_clear_cache_by_class((VALUE)obj);
|
rb_clear_cache_by_class((VALUE)obj);
|
||||||
free_m_table(RCLASS_M_TBL(obj));
|
rb_free_m_table(RCLASS_M_TBL(obj));
|
||||||
if (RCLASS_IV_TBL(obj)) {
|
if (RCLASS_IV_TBL(obj)) {
|
||||||
st_free_table(RCLASS_IV_TBL(obj));
|
st_free_table(RCLASS_IV_TBL(obj));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user