Ask a Question related to Ruby, Design and Development.

  1. #1

    Default Re: I'm stuck

    On Fri, Oct 10, 2003 at 01:15:26AM +0900, Friedrich Dominicus wrote:
    > > >> /* At this step you are playing a dangerous game with the GC */
    > > F> what you you mean which this step ?
    > > F> ruby_init? How should I know what else to set up or use?
    > >
    > > Here a stupid example :
    > >
    > > int main(void)
    > > {
    > > char i;
    > > VALUE obj;
    > > VALUE klass;
    > >
    > > ruby_init();
    > > obj = rb_str_new2("a string");
    > >
    > > /* call some ruby functions which call the GC */
    > >
    > > i = RSTRING(obj)->ptr[0];
    > >
    > > /* there are many chances than the String referenced by obj
    > > was removed by the GC, and you have a segfault when you try
    > > to access RSTRING(obj)->ptr[0] */
    > Ok I understand that now, what do I have to do that it does not
    > happen?
    >
    > What's the simplest but too safe way to solve my simple problem. I
    > just want the C side access the Ruby side as partly pointed out here.
    void do_stuff()
    {
    char i;
    VALUE obj;
    VALUE klass;

    obj = rb_str_new2("a string");

    /* call some ruby functions which call the GC */

    i = RSTRING(obj)->ptr[0];
    ...
    }

    int main(void)
    {
    ruby_init();
    do_stuff();
    }

    --
    _ _
    | |__ __ _| |_ ___ _ __ ___ __ _ _ __
    | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \
    | |_) | (_| | |_\__ \ | | | | | (_| | | | |
    |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
    Running Debian GNU/Linux Sid (unstable)
    batsman dot geo at yahoo dot com

    We apologize for the inconvenience, but we'd still like yout to test out
    this kernel.
    -- Linus Torvalds, announcing another kernel patch

    Mauricio Fernández Guest

  2. Similar Questions and Discussions

    1. CFC Query - stuck, stuck, stuck
      I am once again trying to use Dreamweaver. Here I want to create my first CFC. I'm following the online tutorial Building Your First Database...
    2. Stuck again
      Ok i'm stuck on another one. I have four related tables retailers, products, price and category I need to have a form to add any new retailers....
    3. [PHP] Fw: Am stuck
      On Thu, 25 Sep 2003 15:17:26 +0200 "Chris Grigor" <aphrodit@iafrica.com> wrote: Look up str_pad(). ____ Regards, Andu Novac
    4. stuck with SQL
      If you need to use subqueries, you need to upgrage to MySQL 4.1.x. In 4.0.14 you can restructure your query using a LEFT JOIN on the tables. ...
    5. php.. Am I stuck??
      I purchased a program ( So I thought) that turned out to be just a bunch of php scripts put together. I am getting terrible support from the author...
  3. #2

    Default Re: I'm stuck

    On Fri, Oct 10, 2003 at 01:22:21AM +0900, Friedrich Dominicus wrote:
    > I have another question related to this, aren't there any functions
    > provided to inform the GC that a particular object should not be
    > collected at the moment? As shown I do not know the ins/outs from
    > Ruby, but I have learned about dealing with a copying GC in Eiffel an
    > there some features are provided to exclude a particular object from
    > beein moved. There this function have names with freeze or frozen in
    > it. Is OBJ_FREEZE supposed to do something simular?
    rb_gc_register_address

    or simply keep a reference in the stack

    --
    _ _
    | |__ __ _| |_ ___ _ __ ___ __ _ _ __
    | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \
    | |_) | (_| | |_\__ \ | | | | | (_| | | | |
    |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
    Running Debian GNU/Linux Sid (unstable)
    batsman dot geo at yahoo dot com

    Less is more or less more
    -- Y_Plentyn on #LinuxGER

    Mauricio Fernández Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139