From 56dc6f5acc944e06420614b6c2a475376a887d95 Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 10 Jan 2012 03:49:10 +0000 Subject: * gc.c (ruby_mimmalloc): defined for objects need not rb_objspace, but should return pointer suitable for ruby_xfree; main vm and main thread. patched by Sokolov Yura. https://github.com/ruby/ruby/pull/79 * internal.h: ditto. * vm.c (Init_BareVM): use ruby_mimmalloc. * ext/dl/cfunc.c: #include . * ext/syslog/syslog.c: use xfree because it is allocated by ruby_strdup. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- gc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'gc.c') diff --git a/gc.c b/gc.c index e6a7fcc330..696fb7ab59 100644 --- a/gc.c +++ b/gc.c @@ -941,6 +941,24 @@ ruby_xfree(void *x) } +/* Mimic ruby_xmalloc, but need not rb_objspace. + * should return pointer suitable for ruby_xfree + */ +void * +ruby_mimmalloc(size_t size) +{ + void *mem; +#if CALC_EXACT_MALLOC_SIZE + size += sizeof(size_t); +#endif + mem = malloc(size); +#if CALC_EXACT_MALLOC_SIZE + ((size_t *)mem)[0] = size; + mem = (size_t *)mem + 1; +#endif + return mem; +} + /* * call-seq: * GC.enable -> true or false -- cgit v1.2.3