* 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:
parent
3de7ec0a3f
commit
76b06555d0
@ -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>
|
Thu Oct 17 17:32:51 2013 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* array.c, string.c: use ruby_xsizedfree() and ruby_xsizedrealloc().
|
* array.c, string.c: use ruby_xsizedfree() and ruby_xsizedrealloc().
|
||||||
|
12
array.c
12
array.c
@ -225,7 +225,7 @@ ary_resize_capa(VALUE ary, long capacity)
|
|||||||
MEMCPY((VALUE *)RARRAY(ary)->as.ary, ptr, VALUE, len);
|
MEMCPY((VALUE *)RARRAY(ary)->as.ary, ptr, VALUE, len);
|
||||||
FL_SET_EMBED(ary);
|
FL_SET_EMBED(ary);
|
||||||
ARY_SET_LEN(ary, len);
|
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)
|
rb_ary_free(VALUE ary)
|
||||||
{
|
{
|
||||||
if (ARY_OWNS_HEAP_P(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);
|
rb_ary_modify(ary);
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
if (ARY_OWNS_HEAP_P(ary) && RARRAY_CONST_PTR(ary) != 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);
|
rb_ary_unshare_safe(ary);
|
||||||
FL_SET_EMBED(ary);
|
FL_SET_EMBED(ary);
|
||||||
@ -2436,7 +2436,7 @@ rb_ary_sort_bang(VALUE ary)
|
|||||||
rb_ary_unshare(ary);
|
rb_ary_unshare(ary);
|
||||||
}
|
}
|
||||||
else {
|
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_PTR(ary, RARRAY_CONST_PTR(tmp));
|
||||||
ARY_SET_HEAP_LEN(ary, len);
|
ARY_SET_HEAP_LEN(ary, len);
|
||||||
@ -3300,7 +3300,7 @@ rb_ary_replace(VALUE copy, VALUE orig)
|
|||||||
VALUE shared = 0;
|
VALUE shared = 0;
|
||||||
|
|
||||||
if (ARY_OWNS_HEAP_P(copy)) {
|
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)) {
|
else if (ARY_SHARED_P(copy)) {
|
||||||
shared = ARY_SHARED(copy);
|
shared = ARY_SHARED(copy);
|
||||||
@ -3316,7 +3316,7 @@ rb_ary_replace(VALUE copy, VALUE orig)
|
|||||||
else {
|
else {
|
||||||
VALUE shared = ary_make_shared(orig);
|
VALUE shared = ary_make_shared(orig);
|
||||||
if (ARY_OWNS_HEAP_P(copy)) {
|
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 {
|
else {
|
||||||
rb_ary_unshare_safe(copy);
|
rb_ary_unshare_safe(copy);
|
||||||
|
8
gc.c
8
gc.c
@ -5045,7 +5045,7 @@ ruby_xcalloc(size_t n, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *
|
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);
|
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 *
|
void *
|
||||||
ruby_xrealloc(void *ptr, size_t new_size)
|
ruby_xrealloc(void *ptr, size_t new_size)
|
||||||
{
|
{
|
||||||
return ruby_xsizedrealloc(ptr, new_size, 0);
|
return ruby_sized_xrealloc(ptr, new_size, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
@ -5067,7 +5067,7 @@ ruby_xrealloc2(void *ptr, size_t n, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ruby_xsizedfree(void *x, size_t size)
|
ruby_sized_xfree(void *x, size_t size)
|
||||||
{
|
{
|
||||||
if (x) {
|
if (x) {
|
||||||
vm_xfree(&rb_objspace, x, size);
|
vm_xfree(&rb_objspace, x, size);
|
||||||
@ -5077,7 +5077,7 @@ ruby_xsizedfree(void *x, size_t size)
|
|||||||
void
|
void
|
||||||
ruby_xfree(void *x)
|
ruby_xfree(void *x)
|
||||||
{
|
{
|
||||||
ruby_xsizedfree(x, 0);
|
ruby_sized_xfree(x, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mimic ruby_xmalloc, but need not rb_objspace.
|
/* Mimic ruby_xmalloc, but need not rb_objspace.
|
||||||
|
@ -432,9 +432,9 @@ void *ruby_mimmalloc(size_t size);
|
|||||||
void rb_objspace_set_event_hook(const rb_event_flag_t event);
|
void rb_objspace_set_event_hook(const rb_event_flag_t event);
|
||||||
void rb_gc_writebarrier_remember_promoted(VALUE obj);
|
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_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_ALLOC_SIZE((2));;
|
||||||
void ruby_xsizedfree(void *x, size_t size);
|
void ruby_sized_xfree(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)))
|
#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 */
|
/* hash.c */
|
||||||
struct st_table *rb_hash_tbl_raw(VALUE hash);
|
struct st_table *rb_hash_tbl_raw(VALUE hash);
|
||||||
|
10
string.c
10
string.c
@ -883,7 +883,7 @@ rb_str_free(VALUE str)
|
|||||||
st_delete(frozen_strings, &fstr, NULL);
|
st_delete(frozen_strings, &fstr, NULL);
|
||||||
}
|
}
|
||||||
if (!STR_EMBED_P(str) && !STR_SHARED_P(str)) {
|
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);
|
str_modifiable(str);
|
||||||
if (!STR_SHARED_P(str) && !STR_EMBED_P(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.ptr = 0;
|
||||||
RSTRING(str)->as.heap.len = 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);
|
if (slen > 0) MEMCPY(RSTRING(str)->as.ary, ptr, char, slen);
|
||||||
TERM_FILL(RSTRING(str)->as.ary + len, termlen);
|
TERM_FILL(RSTRING(str)->as.ary + len, termlen);
|
||||||
STR_SET_EMBED_LEN(str, len);
|
STR_SET_EMBED_LEN(str, len);
|
||||||
if (independent) ruby_xsizedfree(ptr, size);
|
if (independent) ruby_sized_xfree(ptr, size);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
else if (!independent) {
|
else if (!independent) {
|
||||||
@ -5501,7 +5501,7 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
|
|||||||
t += tlen;
|
t += tlen;
|
||||||
}
|
}
|
||||||
if (!STR_EMBED_P(str)) {
|
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';
|
*t = '\0';
|
||||||
RSTRING(str)->as.heap.ptr = buf;
|
RSTRING(str)->as.heap.ptr = buf;
|
||||||
@ -5577,7 +5577,7 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
|
|||||||
t += tlen;
|
t += tlen;
|
||||||
}
|
}
|
||||||
if (!STR_EMBED_P(str)) {
|
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';
|
*t = '\0';
|
||||||
RSTRING(str)->as.heap.ptr = buf;
|
RSTRING(str)->as.heap.ptr = buf;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user