1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* gc.c, internal.h: rename ruby_xsizefree/realloc to

rb_sized_free/realloc.
* array.c: catch up these changes.
* string.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2013-10-17 08:41:23 +00:00
parent 3de7ec0a3f
commit 76b06555d0
5 changed files with 27 additions and 18 deletions

View file

@ -1,3 +1,12 @@
Thu Oct 17 17:38:36 2013 Koichi Sasada <ko1@atdot.net>
* gc.c, internal.h: rename ruby_xsizefree/realloc to
rb_sized_free/realloc.
* array.c: catch up these changes.
* string.c: ditto.
Thu Oct 17 17:32:51 2013 Koichi Sasada <ko1@atdot.net>
* array.c, string.c: use ruby_xsizedfree() and ruby_xsizedrealloc().

12
array.c
View file

@ -225,7 +225,7 @@ ary_resize_capa(VALUE ary, long capacity)
MEMCPY((VALUE *)RARRAY(ary)->as.ary, ptr, VALUE, len);
FL_SET_EMBED(ary);
ARY_SET_LEN(ary, len);
ruby_xsizedfree((VALUE *)ptr, size);
ruby_sized_xfree((VALUE *)ptr, size);
}
}
}
@ -536,7 +536,7 @@ void
rb_ary_free(VALUE ary)
{
if (ARY_OWNS_HEAP_P(ary)) {
ruby_xsizedfree((void *)ARY_HEAP_PTR(ary), ARY_HEAP_SIZE(ary));
ruby_sized_xfree((void *)ARY_HEAP_PTR(ary), ARY_HEAP_SIZE(ary));
}
}
@ -716,7 +716,7 @@ rb_ary_initialize(int argc, VALUE *argv, VALUE ary)
rb_ary_modify(ary);
if (argc == 0) {
if (ARY_OWNS_HEAP_P(ary) && RARRAY_CONST_PTR(ary) != 0) {
ruby_xsizedfree((void *)RARRAY_CONST_PTR(ary), ARY_HEAP_SIZE(ary));
ruby_sized_xfree((void *)RARRAY_CONST_PTR(ary), ARY_HEAP_SIZE(ary));
}
rb_ary_unshare_safe(ary);
FL_SET_EMBED(ary);
@ -2436,7 +2436,7 @@ rb_ary_sort_bang(VALUE ary)
rb_ary_unshare(ary);
}
else {
ruby_xsizedfree((void *)ARY_HEAP_PTR(ary), ARY_HEAP_SIZE(ary));
ruby_sized_xfree((void *)ARY_HEAP_PTR(ary), ARY_HEAP_SIZE(ary));
}
ARY_SET_PTR(ary, RARRAY_CONST_PTR(tmp));
ARY_SET_HEAP_LEN(ary, len);
@ -3300,7 +3300,7 @@ rb_ary_replace(VALUE copy, VALUE orig)
VALUE shared = 0;
if (ARY_OWNS_HEAP_P(copy)) {
RARRAY_PTR_USE(copy, ptr, ruby_xsizedfree(ptr, ARY_HEAP_SIZE(copy)));
RARRAY_PTR_USE(copy, ptr, ruby_sized_xfree(ptr, ARY_HEAP_SIZE(copy)));
}
else if (ARY_SHARED_P(copy)) {
shared = ARY_SHARED(copy);
@ -3316,7 +3316,7 @@ rb_ary_replace(VALUE copy, VALUE orig)
else {
VALUE shared = ary_make_shared(orig);
if (ARY_OWNS_HEAP_P(copy)) {
RARRAY_PTR_USE(copy, ptr, ruby_xsizedfree(ptr, ARY_HEAP_SIZE(copy)));
RARRAY_PTR_USE(copy, ptr, ruby_sized_xfree(ptr, ARY_HEAP_SIZE(copy)));
}
else {
rb_ary_unshare_safe(copy);

8
gc.c
View file

@ -5045,7 +5045,7 @@ ruby_xcalloc(size_t n, size_t size)
}
void *
ruby_xsizedrealloc(void *ptr, size_t new_size, size_t old_size)
ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size)
{
return vm_xrealloc(&rb_objspace, ptr, new_size, old_size);
}
@ -5053,7 +5053,7 @@ ruby_xsizedrealloc(void *ptr, size_t new_size, size_t old_size)
void *
ruby_xrealloc(void *ptr, size_t new_size)
{
return ruby_xsizedrealloc(ptr, new_size, 0);
return ruby_sized_xrealloc(ptr, new_size, 0);
}
void *
@ -5067,7 +5067,7 @@ ruby_xrealloc2(void *ptr, size_t n, size_t size)
}
void
ruby_xsizedfree(void *x, size_t size)
ruby_sized_xfree(void *x, size_t size)
{
if (x) {
vm_xfree(&rb_objspace, x, size);
@ -5077,7 +5077,7 @@ ruby_xsizedfree(void *x, size_t size)
void
ruby_xfree(void *x)
{
ruby_xsizedfree(x, 0);
ruby_sized_xfree(x, 0);
}
/* Mimic ruby_xmalloc, but need not rb_objspace.

View file

@ -432,9 +432,9 @@ void *ruby_mimmalloc(size_t size);
void rb_objspace_set_event_hook(const rb_event_flag_t event);
void rb_gc_writebarrier_remember_promoted(VALUE obj);
void *ruby_xsizedrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_ALLOC_SIZE((2));;
void ruby_xsizedfree(void *x, size_t size);
#define SIZED_REALLOC_N(var,type,n,old_n) ((var)=(type*)ruby_xsizedrealloc((char*)(var), (n) * sizeof(type), (old_n) * sizeof(type)))
void *ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_ALLOC_SIZE((2));;
void ruby_sized_xfree(void *x, size_t size);
#define SIZED_REALLOC_N(var,type,n,old_n) ((var)=(type*)ruby_sized_xrealloc((char*)(var), (n) * sizeof(type), (old_n) * sizeof(type)))
/* hash.c */
struct st_table *rb_hash_tbl_raw(VALUE hash);

View file

@ -883,7 +883,7 @@ rb_str_free(VALUE str)
st_delete(frozen_strings, &fstr, NULL);
}
if (!STR_EMBED_P(str) && !STR_SHARED_P(str)) {
ruby_xsizedfree(STR_HEAP_PTR(str), STR_HEAP_SIZE(str));
ruby_sized_xfree(STR_HEAP_PTR(str), STR_HEAP_SIZE(str));
}
}
@ -1466,7 +1466,7 @@ str_discard(VALUE str)
{
str_modifiable(str);
if (!STR_SHARED_P(str) && !STR_EMBED_P(str)) {
ruby_xsizedfree(STR_HEAP_PTR(str), STR_HEAP_SIZE(str));
ruby_sized_xfree(STR_HEAP_PTR(str), STR_HEAP_SIZE(str));
RSTRING(str)->as.heap.ptr = 0;
RSTRING(str)->as.heap.len = 0;
}
@ -1990,7 +1990,7 @@ rb_str_resize(VALUE str, long len)
if (slen > 0) MEMCPY(RSTRING(str)->as.ary, ptr, char, slen);
TERM_FILL(RSTRING(str)->as.ary + len, termlen);
STR_SET_EMBED_LEN(str, len);
if (independent) ruby_xsizedfree(ptr, size);
if (independent) ruby_sized_xfree(ptr, size);
return str;
}
else if (!independent) {
@ -5501,7 +5501,7 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
t += tlen;
}
if (!STR_EMBED_P(str)) {
ruby_xsizedfree(STR_HEAP_PTR(str), STR_HEAP_SIZE(str));
ruby_sized_xfree(STR_HEAP_PTR(str), STR_HEAP_SIZE(str));
}
*t = '\0';
RSTRING(str)->as.heap.ptr = buf;
@ -5577,7 +5577,7 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
t += tlen;
}
if (!STR_EMBED_P(str)) {
ruby_xsizedfree(STR_HEAP_PTR(str), STR_HEAP_SIZE(str));
ruby_sized_xfree(STR_HEAP_PTR(str), STR_HEAP_SIZE(str));
}
*t = '\0';
RSTRING(str)->as.heap.ptr = buf;