Project

General

Profile

Feature #10238 ยป 0001-gc.c-use-ruby_sized_xfree-in-more-places.patch

normalperson (Eric Wong), 05/18/2018 09:24 PM

View differences:

gc.c
static void free_stack_chunks(mark_stack_t *);
static void heap_page_free(rb_objspace_t *objspace, struct heap_page *page);
#ifdef ruby_sized_xfree
#undef ruby_sized_xfree
#endif
void ruby_sized_xfree(void *, size_t);
#define SIZED_XFREE(p) ruby_sized_xfree(p,sizeof(*p))
void
rb_objspace_free(rb_objspace_t *objspace)
{
......
struct gc_list *list, *next;
for (list = global_list; list; list = next) {
next = list->next;
xfree(list);
SIZED_XFREE(list);
}
}
if (heap_pages_sorted) {
......
free_const_entry_i(VALUE value, void *data)
{
rb_const_entry_t *ce = (rb_const_entry_t *)value;
xfree(ce);
SIZED_XFREE(ce);
return ID_TABLE_CONTINUE;
}
......
rb_class_remove_from_module_subclasses(obj);
rb_class_remove_from_super_subclasses(obj);
if (RANY(obj)->as.klass.ptr)
xfree(RANY(obj)->as.klass.ptr);
SIZED_XFREE(RANY(obj)->as.klass.ptr);
RANY(obj)->as.klass.ptr = NULL;
break;
case T_STRING:
......
struct rmatch *rm = RANY(obj)->as.match.rmatch;
onig_region_free(&rm->regs, 0);
if (rm->char_offset)
xfree(rm->char_offset);
xfree(rm);
SIZED_XFREE(rm->char_offset);
SIZED_XFREE(rm);
}
break;
case T_FILE:
......
}
rb_class_remove_from_module_subclasses(obj);
rb_class_remove_from_super_subclasses(obj);
xfree(RANY(obj)->as.klass.ptr);
SIZED_XFREE(RANY(obj)->as.klass.ptr);
RANY(obj)->as.klass.ptr = NULL;
break;
......
run_finalizer(objspace, curr->obj, curr->table);
st_delete(finalizer_table, &obj, 0);
list = curr->next;
xfree(curr);
SIZED_XFREE(curr);
}
}
......
reflist_destruct(struct reflist *refs)
{
xfree(refs->list);
xfree(refs);
SIZED_XFREE(refs);
}
static void
......
if (tmp->varptr == addr) {
global_list = tmp->next;
xfree(tmp);
SIZED_XFREE(tmp);
return;
}
while (tmp->next) {
......
struct gc_list *t = tmp->next;
tmp->next = tmp->next->next;
xfree(t);
SIZED_XFREE(t);
break;
}
tmp = tmp->next;
......
return ruby_sized_xrealloc2(ptr, n, size, 0);
}
#ifdef ruby_sized_xfree
#undef ruby_sized_xfree
#endif
void
ruby_sized_xfree(void *x, size_t size)
{
-
    (1-1/1)