>>>>> "S" == Sean O'Dell <sean / cSePlsoAfMt.com[REMOVE_THE_SPAM]> writes:

S> ts wrote:
[...]
>> rb_load_protect (rb_str_new2(script), Qfalse, &state);
[...]
S> That's interesting; does this way work because Ruby marks the stack and 
S> it was being loaded within an if block, and moving the load calls to a 
S> permanent place on the stack solves the problem?

 No, read carefully my example and the original message. In the original
 message there is rb_load_file(), but I use rb_load_protect()

  * rb_load_file() read a file and compile it into an AST

  * rb_load_protect() call rb_load() but trap all errors (to be sure to
    don't crash the executable if ruby find an error)
     * rb_load() call rb_load_file() *and then* execute the nodes.


 Now if it's written like this

>> int main (int argc, char **argv)
>> {
>> ruby_init ();
>> ruby_init_loadpath ();      /* to find the libraries */
>> return execute(argc, argv);
>> }                               // end of main

 this is to try to protect the VALUE res, if ruby call the GC


Guy Decoux