* internal.h: do not use ruby_sized_xrealloc() and ruby_sized_xfree()
if HAVE_MALLOC_USABLE_SIZE (or _WIN32) is defined. We don't need these function if malloc_usable_size() is available. * gc.c: catch up this change. * gc.c: define HAVE_MALLOC_USABLE_SIZE on _WIN32. * array.c (ary_resize_capa): do not use ruby_sized_xfree() with local variable to avoid "unused local variable" warning. This change only has few impact. * string.c (rb_str_resize): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
84b7d6d533
commit
2bfd722d80
17
ChangeLog
17
ChangeLog
@ -1,3 +1,20 @@
|
|||||||
|
Mon Nov 25 06:53:30 2013 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* internal.h: do not use ruby_sized_xrealloc() and ruby_sized_xfree()
|
||||||
|
if HAVE_MALLOC_USABLE_SIZE (or _WIN32) is defined.
|
||||||
|
|
||||||
|
We don't need these function if malloc_usable_size() is available.
|
||||||
|
|
||||||
|
* gc.c: catch up this change.
|
||||||
|
|
||||||
|
* gc.c: define HAVE_MALLOC_USABLE_SIZE on _WIN32.
|
||||||
|
|
||||||
|
* array.c (ary_resize_capa): do not use ruby_sized_xfree() with
|
||||||
|
local variable to avoid "unused local variable" warning.
|
||||||
|
This change only has few impact.
|
||||||
|
|
||||||
|
* string.c (rb_str_resize): ditto.
|
||||||
|
|
||||||
Mon Nov 25 05:05:04 2013 Koichi Sasada <ko1@atdot.net>
|
Mon Nov 25 05:05:04 2013 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* test/-ext-/tracepoint/test_tracepoint.rb: catch up GC.stat changes
|
* test/-ext-/tracepoint/test_tracepoint.rb: catch up GC.stat changes
|
||||||
|
3
array.c
3
array.c
@ -219,13 +219,12 @@ ary_resize_capa(VALUE ary, long capacity)
|
|||||||
if (!ARY_EMBED_P(ary)) {
|
if (!ARY_EMBED_P(ary)) {
|
||||||
long len = RARRAY_LEN(ary);
|
long len = RARRAY_LEN(ary);
|
||||||
const VALUE *ptr = RARRAY_CONST_PTR(ary);
|
const VALUE *ptr = RARRAY_CONST_PTR(ary);
|
||||||
size_t size = ARY_HEAP_SIZE(ary);
|
|
||||||
|
|
||||||
if (len > capacity) len = capacity;
|
if (len > capacity) len = 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_sized_xfree((VALUE *)ptr, size);
|
ruby_xfree((VALUE *)ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
7
gc.c
7
gc.c
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
#ifndef HAVE_MALLOC_USABLE_SIZE
|
#ifndef HAVE_MALLOC_USABLE_SIZE
|
||||||
# ifdef _WIN32
|
# ifdef _WIN32
|
||||||
|
# define HAVE_MALLOC_USABLE_SIZE
|
||||||
# define malloc_usable_size(a) _msize(a)
|
# define malloc_usable_size(a) _msize(a)
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
@ -5753,6 +5754,9 @@ ruby_xcalloc(size_t n, size_t size)
|
|||||||
return vm_xcalloc(&rb_objspace, n, size);
|
return vm_xcalloc(&rb_objspace, n, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ruby_sized_xrealloc
|
||||||
|
#undef ruby_sized_xrealloc
|
||||||
|
#endif
|
||||||
void *
|
void *
|
||||||
ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size)
|
ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size)
|
||||||
{
|
{
|
||||||
@ -5775,6 +5779,9 @@ ruby_xrealloc2(void *ptr, size_t n, size_t size)
|
|||||||
return ruby_xrealloc(ptr, len);
|
return ruby_xrealloc(ptr, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ruby_sized_xfree
|
||||||
|
#undef ruby_sized_xfree
|
||||||
|
#endif
|
||||||
void
|
void
|
||||||
ruby_sized_xfree(void *x, size_t size)
|
ruby_sized_xfree(void *x, size_t size)
|
||||||
{
|
{
|
||||||
|
@ -439,9 +439,15 @@ 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_gc_set_params(void);
|
void ruby_gc_set_params(void);
|
||||||
|
|
||||||
|
#if HAVE_MALLOC_USABLE_SIZE || defined(_WIN32)
|
||||||
|
#define ruby_sized_xrealloc(ptr, new_size, old_size) ruby_xrealloc(ptr, new_size)
|
||||||
|
#define ruby_sized_xfree(ptr, size) ruby_xfree(ptr)
|
||||||
|
#define SIZED_REALLOC_N(var,type,n,old_n) REALLOC_N(var, type, n)
|
||||||
|
#else
|
||||||
void *ruby_sized_xrealloc(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_sized_xfree(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_sized_xrealloc((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)))
|
||||||
|
#endif
|
||||||
|
|
||||||
void rb_gc_resurrect(VALUE ptr);
|
void rb_gc_resurrect(VALUE ptr);
|
||||||
|
|
||||||
|
3
string.c
3
string.c
@ -1973,13 +1973,12 @@ rb_str_resize(VALUE str, long len)
|
|||||||
}
|
}
|
||||||
else if (len + termlen <= RSTRING_EMBED_LEN_MAX + 1) {
|
else if (len + termlen <= RSTRING_EMBED_LEN_MAX + 1) {
|
||||||
char *ptr = STR_HEAP_PTR(str);
|
char *ptr = STR_HEAP_PTR(str);
|
||||||
size_t size = STR_HEAP_SIZE(str);
|
|
||||||
STR_SET_EMBED(str);
|
STR_SET_EMBED(str);
|
||||||
if (slen > len) slen = len;
|
if (slen > len) slen = 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_sized_xfree(ptr, size);
|
if (independent) ruby_xfree(ptr);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
else if (!independent) {
|
else if (!independent) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user