Tim Pease wrote:
> On Jul 6, 2008, at 7:15 PM, Nobuyoshi Nakada wrote:
...
>>     VALUE x, array;
>>     char **foo = malloc(buncha char *);
>>
>>     for (big list of things) {
>>         x = rb_obj_as_string(y);
>>         rb_ary_push(array, x);
>>         foo[i] = GetStringValue(x);
>>     }
>>
>> By keeping the values in an automatic variable `array', they
>> are marked and won't be freed.
>>
> 
> I am wondering why the strings (returned from rb_obj_as_string) will be 
> garbage collected but the array will not be garbage collected? Both have 
> the same local scope, and they are not referenced by any other ruby object.

IIUC, 'VALUE array' is a local, hence on stack, hence GC marks it. The 
'VALUE x' local only protects the current string.

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407