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
1342 1342
static void free_stack_chunks(mark_stack_t *);
1343 1343
static void heap_page_free(rb_objspace_t *objspace, struct heap_page *page);
1344 1344

  
1345
#ifdef ruby_sized_xfree
1346
#undef ruby_sized_xfree
1347
#endif
1348
void ruby_sized_xfree(void *, size_t);
1349
#define SIZED_XFREE(p) ruby_sized_xfree(p,sizeof(*p))
1350

  
1345 1351
void
1346 1352
rb_objspace_free(rb_objspace_t *objspace)
1347 1353
{
......
1357 1363
	struct gc_list *list, *next;
1358 1364
	for (list = global_list; list; list = next) {
1359 1365
	    next = list->next;
1360
	    xfree(list);
1366
	    SIZED_XFREE(list);
1361 1367
	}
1362 1368
    }
1363 1369
    if (heap_pages_sorted) {
......
2149 2155
free_const_entry_i(VALUE value, void *data)
2150 2156
{
2151 2157
    rb_const_entry_t *ce = (rb_const_entry_t *)value;
2152
    xfree(ce);
2158
    SIZED_XFREE(ce);
2153 2159
    return ID_TABLE_CONTINUE;
2154 2160
}
2155 2161

  
......
2248 2254
	rb_class_remove_from_module_subclasses(obj);
2249 2255
	rb_class_remove_from_super_subclasses(obj);
2250 2256
	if (RANY(obj)->as.klass.ptr)
2251
	    xfree(RANY(obj)->as.klass.ptr);
2257
	    SIZED_XFREE(RANY(obj)->as.klass.ptr);
2252 2258
	RANY(obj)->as.klass.ptr = NULL;
2253 2259
	break;
2254 2260
      case T_STRING:
......
2304 2310
            struct rmatch *rm = RANY(obj)->as.match.rmatch;
2305 2311
	    onig_region_free(&rm->regs, 0);
2306 2312
            if (rm->char_offset)
2307
		xfree(rm->char_offset);
2308
	    xfree(rm);
2313
		SIZED_XFREE(rm->char_offset);
2314
	    SIZED_XFREE(rm);
2309 2315
	}
2310 2316
	break;
2311 2317
      case T_FILE:
......
2331 2337
	}
2332 2338
	rb_class_remove_from_module_subclasses(obj);
2333 2339
	rb_class_remove_from_super_subclasses(obj);
2334
	xfree(RANY(obj)->as.klass.ptr);
2340
	SIZED_XFREE(RANY(obj)->as.klass.ptr);
2335 2341
	RANY(obj)->as.klass.ptr = NULL;
2336 2342
	break;
2337 2343

  
......
2954 2960
	    run_finalizer(objspace, curr->obj, curr->table);
2955 2961
	    st_delete(finalizer_table, &obj, 0);
2956 2962
	    list = curr->next;
2957
	    xfree(curr);
2963
	    SIZED_XFREE(curr);
2958 2964
	}
2959 2965
    }
2960 2966

  
......
4905 4911
reflist_destruct(struct reflist *refs)
4906 4912
{
4907 4913
    xfree(refs->list);
4908
    xfree(refs);
4914
    SIZED_XFREE(refs);
4909 4915
}
4910 4916

  
4911 4917
static void
......
6270 6276

  
6271 6277
    if (tmp->varptr == addr) {
6272 6278
	global_list = tmp->next;
6273
	xfree(tmp);
6279
	SIZED_XFREE(tmp);
6274 6280
	return;
6275 6281
    }
6276 6282
    while (tmp->next) {
......
6278 6284
	    struct gc_list *t = tmp->next;
6279 6285

  
6280 6286
	    tmp->next = tmp->next->next;
6281
	    xfree(t);
6287
	    SIZED_XFREE(t);
6282 6288
	    break;
6283 6289
	}
6284 6290
	tmp = tmp->next;
......
8074 8080
    return ruby_sized_xrealloc2(ptr, n, size, 0);
8075 8081
}
8076 8082

  
8077
#ifdef ruby_sized_xfree
8078
#undef ruby_sized_xfree
8079
#endif
8080 8083
void
8081 8084
ruby_sized_xfree(void *x, size_t size)
8082 8085
{
8083
-