On Wed, 25 Jun 2003 20:15:25 +0000, Shashank Date wrote:

> 
> "Simon Strandgaard" <0bz63fz3m1qt3001 / sneakemail.com>
>>
>> Can you post the whole program, then I will see what I can do ?
> 
> Try commenting out the line marked by <===== below.

Ok.. I also commented out Init_stack() because I don't know what it does.
This code works.. I have no segfaults ?


> expand -t2 main.c
#include <ruby.h>

int main(int Argc, char **Argv) {
  int argc;
  VALUE argv[2];
  VALUE klass;
  VALUE instance;

  ruby_init();
  //Init_stack(&argc); // tell GC the machine stack limit.

  argv[0] = INT2FIX(5);
  argc    = 2;
  klass    = rb_path2class("Array");
  argv[1]  = rb_str_new2("hello");
  instance = rb_class_new_instance(argc, argv, klass);
  rb_p(instance);

  // Uncommenting the next line will cause the program to crash
  klass = rb_const_get(rb_cObject, rb_intern("Array")); //<=====
  argv[1] = rb_str_new2("world");
  instance= rb_funcall2(klass, rb_intern("new"), argc, argv);

  //No need, see [ruby-talk 74400]
  //rb_gc_register_address(&instance);

  rb_p(instance);
  ruby_finalize();
  return 0;
}
>

> ./a.out
["hello", "hello", "hello", "hello", "hello"]
["world", "world", "world", "world", "world"]
>

--
Simon Strandgaard