From: Tim Hunter on 24 Oct 2009 13:06 I�aki Baz Castillo wrote: > > It's a small piece of C code, no more. Do you mean that I shouldn't use > "malloc"/"free" in a Ruby C extension? > Of course you can. Just be prepared to free the memory before raising an exception. Also check out Ruby's xmalloc and xfree. These functions act like malloc and free but the memory will be garbage collected when Ruby determines that there are no more references to it.
From: Yukihiro Matsumoto on 24 Oct 2009 13:28 Hi, In message "Re: C extension: "malloc" and "rb_raise"" on Sun, 25 Oct 2009 02:06:42 +0900, Tim Hunter <TimHunter(a)nc.rr.com> writes: |Also check out Ruby's xmalloc and xfree. These functions act |like malloc and free but the memory will be garbage collected when Ruby |determines that there are no more references to it. Unfortunately, regions allocated by xmalloc() will not be garbage collected. You still need to deallocate them by xfree(). The difference is that garbage collector will be kicked when a) underlying malloc() failed, b) certain amount of memory region is allocated, to make more free space. matz.
From: Bertram Scharpf on 24 Oct 2009 18:09 Hi, Am Sonntag, 25. Okt 2009, 00:32:43 +0900 schrieb Iñaki Baz Castillo: > El Sábado, 24 de Octubre de 2009, Bertram Scharpf escribió: > > It's a small piece of C code, no more. Do you mean that I shouldn't use > "malloc"/"free" in a Ruby C extension? README.EXT recommends to allocate space by the ALLOC() macro which calls Ruby's xmalloc(). I cannot find an xfree() call there; I admit I do not understand that. Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de
First
|
Prev
|
Pages: 1 2 Prev: Net:HTTP Timeout Bug Next: add_assertion' called for nil:NilClass errror when testing |