retain VALUE from C extension

Discussion in 'Ruby' started by Gaspard Bucher, Oct 10, 2007.

  1. 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;
    }
     
    Gaspard Bucher, Oct 10, 2007
    #1
    1. Advertising

  2. 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
     
    Gaspard Bucher, Oct 10, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KathyB
    Replies:
    6
    Views:
    583
    Todd Thompson
    Jun 27, 2003
  2. John Blair
    Replies:
    2
    Views:
    7,902
    John Blair
    Aug 2, 2005
  3. Harinath
    Replies:
    1
    Views:
    541
    Patrice
    Dec 22, 2006
  4. Replies:
    8
    Views:
    336
    Roy Gourgi
    Jun 28, 2005
  5. Replies:
    5
    Views:
    311
Loading...

Share This Page