Skip to content

Commit

Permalink
* gc.c, internal.h: rename ruby_xsizefree/realloc to
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
ko1 committed Oct 17, 2013
1 parent 3de7ec0 commit 76b0655
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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().
Expand Down
12 changes: 6 additions & 6 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5045,15 +5045,15 @@ 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);
}

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 *
Expand All @@ -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);
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 76b0655

Please sign in to comment.