retain VALUE from C extension

G

Gaspard Bucher

How do I tell ruby to increment it's garbage collector if I want to
keep hold of a VALUE in a C extension.

example:

VALUE message;

static VALUE store_message(VALUE self, VALUE msg) {
// tell ruby to retain....
// rb_retain(msg) ?
message = msg;
return Qnil;
}
 
G

Gaspard Bucher

Yes, I think this is what I was looking for. As I understand, this
"declares" the address as needing "global marking" by adding it to
global_List.
/* mark protected global variables */
for (list = global_List; list; list = list->next) {
rb_gc_mark_maybe(*list->varptr);
}
I'm not sure what you mean by 'increment' or 'retain', but
rb_global_variable() may be the answer. See README.EXT.

matz.
Effectivelly, "retain" (objective-C terminology) is not appropriate.
From what I understand the mark & sweep garbage collecting process is
quite different from the reference counting strategy I was familiar
with.

Thanks for the information.

Gaspard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top