From: "Mauricio Fernández" Date: 2003-04-16T16:27:59+09:00 Subject: Re: tutorial on embedding ruby (review) On Wed, Apr 16, 2003 at 10:09:25AM +0900, Steve Hart wrote: > Err.... > Perhaps I should have mentioned I am using swig. > OK Here is an example > > main() > { > ruby_init(); > etc > > test() > rb_gc(); > } > > void test() > { > VALUE v = create me a ruby obj i dont care how > } > > So what happens to v? Gets GC'ed because v goes out of scope and there's thus no reference to the Ruby object in the C stack anymore. > or > > main() > { > > VALUE v; > > ruby_init(); > etc > > test(&v) > rb_gc(); > > do some stuff that uses v > } > > void test( > VALUE *v) > { > *v = create me a ruby obj i dont care how > } GC'ed too because the base of the stack is recorded in ruby_init, so v won't be in the memory area the GC scans for VALUEs. Workaround: int main() { ruby_init(); do_stuff(); } do_stuff() { VALUE v; test(&v); rb_gc(); do some stuff that uses v } > My understanding is that v gets deleted in both cases (well, at least > the first, can't remember what the thread said about the second case - > but there again. I've read so many!). Look, it's 1.30 in the morning. > I have a live transmission in 2 weweks time on BBC national TV. I sold Guess that's as hard a deadline as it gets :| > ruby/swig/OpenGL/Qt to my bosses over their choice for using NT (those > fools!). I KNOW this will work so please help all you ruby/swig > developers or else I am going to give it all up and become a dustman > (pun intended!) > My colleague says I should not post this but hey..... -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Actually, typing random strings in the Finder does the equivalent of filename completion. -- Discussion on file completion vs. the Mac Finder