ext/objspace/object_tracing.c: get rid of aliasing pointers
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5b476b4ad0
commit
4ff0ce6a79
@ -39,7 +39,8 @@ make_unique_str(st_table *tbl, const char *str, long len)
|
||||
|
||||
if (st_lookup(tbl, (st_data_t)str, &n)) {
|
||||
st_insert(tbl, (st_data_t)str, n+1);
|
||||
st_get_key(tbl, (st_data_t)str, (st_data_t *)&result);
|
||||
st_get_key(tbl, (st_data_t)str, &n);
|
||||
result = (char *)n;
|
||||
}
|
||||
else {
|
||||
result = (char *)ruby_xmalloc(len+1);
|
||||
@ -59,8 +60,9 @@ delete_unique_str(st_table *tbl, const char *str)
|
||||
|
||||
st_lookup(tbl, (st_data_t)str, &n);
|
||||
if (n == 1) {
|
||||
st_delete(tbl, (st_data_t *)&str, 0);
|
||||
ruby_xfree((char *)str);
|
||||
n = (st_data_t)str;
|
||||
st_delete(tbl, &n, 0);
|
||||
ruby_xfree((char *)n);
|
||||
}
|
||||
else {
|
||||
st_insert(tbl, (st_data_t)str, n-1);
|
||||
@ -82,8 +84,10 @@ newobj_i(VALUE tpval, void *data)
|
||||
const char *path_cstr = RTEST(path) ? make_unique_str(arg->str_table, RSTRING_PTR(path), RSTRING_LEN(path)) : 0;
|
||||
VALUE class_path = (RTEST(klass) && !OBJ_FROZEN(klass)) ? rb_class_path_cached(klass) : Qnil;
|
||||
const char *class_path_cstr = RTEST(class_path) ? make_unique_str(arg->str_table, RSTRING_PTR(class_path), RSTRING_LEN(class_path)) : 0;
|
||||
st_data_t v;
|
||||
|
||||
if (st_lookup(arg->object_table, (st_data_t)obj, (st_data_t *)&info)) {
|
||||
if (st_lookup(arg->object_table, (st_data_t)obj, &v)) {
|
||||
info = (struct allocation_info *)v;
|
||||
if (arg->keep_remains) {
|
||||
if (info->living) {
|
||||
/* do nothing. there is possibility to keep living if FREEOBJ events while suppressing tracing */
|
||||
@ -113,15 +117,17 @@ freeobj_i(VALUE tpval, void *data)
|
||||
{
|
||||
struct traceobj_arg *arg = (struct traceobj_arg *)data;
|
||||
rb_trace_arg_t *tparg = rb_tracearg_from_tracepoint(tpval);
|
||||
VALUE obj = rb_tracearg_object(tparg);
|
||||
st_data_t obj = (st_data_t)rb_tracearg_object(tparg);
|
||||
st_data_t v;
|
||||
struct allocation_info *info;
|
||||
|
||||
if (st_lookup(arg->object_table, (st_data_t)obj, (st_data_t *)&info)) {
|
||||
if (st_lookup(arg->object_table, obj, &v)) {
|
||||
info = (struct allocation_info *)v;
|
||||
if (arg->keep_remains) {
|
||||
info->living = 0;
|
||||
}
|
||||
else {
|
||||
st_delete(arg->object_table, (st_data_t *)&obj, (st_data_t *)&info);
|
||||
st_delete(arg->object_table, &obj, &v);
|
||||
delete_unique_str(arg->str_table, info->path);
|
||||
delete_unique_str(arg->str_table, info->class_path);
|
||||
ruby_xfree(info);
|
||||
@ -321,9 +327,9 @@ static struct allocation_info *
|
||||
lookup_allocation_info(VALUE obj)
|
||||
{
|
||||
if (tmp_trace_arg) {
|
||||
struct allocation_info *info;
|
||||
if (st_lookup(tmp_trace_arg->object_table, obj, (st_data_t *)&info)) {
|
||||
return info;
|
||||
st_data_t info;
|
||||
if (st_lookup(tmp_trace_arg->object_table, obj, &info)) {
|
||||
return (struct allocation_info *)info;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user