diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-10 07:16:06 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-10 07:16:06 +0000 |
commit | bcdad3299b1d7c53ed08fa23c26a5e7cc99bcac2 (patch) | |
tree | 06e514ab6f3d73d5649150befd3cfb440a0fb51c /gc.c | |
parent | d5526f3fe5edfcbcb72df5f4aff0ed0825b39850 (diff) | |
download | ruby-bcdad3299b1d7c53ed08fa23c26a5e7cc99bcac2.tar.gz |
gc.c: ruby_sized_xrealloc2
* gc.c (ruby_sized_xrealloc2): reallocate from old size.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -6122,14 +6122,23 @@ ruby_xrealloc(void *ptr, size_t new_size) return ruby_sized_xrealloc(ptr, new_size, 0); } +#ifdef ruby_sized_xrealloc2 +#undef ruby_sized_xrealloc2 +#endif void * -ruby_xrealloc2(void *ptr, size_t n, size_t size) +ruby_sized_xrealloc2(void *ptr, size_t n, size_t size, size_t old_n) { size_t len = size * n; if (n != 0 && size != len / n) { rb_raise(rb_eArgError, "realloc: possible integer overflow"); } - return ruby_xrealloc(ptr, len); + return objspace_xrealloc(&rb_objspace, ptr, len, old_n * size); +} + +void * +ruby_xrealloc2(void *ptr, size_t n, size_t size) +{ + return ruby_sized_xrealloc2(ptr, n, size, 0); } #ifdef ruby_sized_xfree |