Ryan Davis wrote:
> Chapter 21 of the Pickaxe (2nd ed) is what you want. It covers this
> topic fairly well.

I'm not exposing a Ruby object though.  Also, the order in which the 
objects are freed when the interpreter process exits matters: if my 
world object is freed before the instances, there will be a segmentation 
fault.  The order in which circularly referenced objects are freed at 
exit seems to be undefined, so maintaining a reference for every object 
won't work well.

As I said before, I tried something along the lines of:

  my_global_object *world;
  VALUE world_holder;

  void Init_extension()
  {
     world = create_world();
     world_holder = Data_Wrap_Struct(rb_cObject, 0, 
free_my_global_object, world);
     rb_global_variable(world_holder);
  }

but still get segmentation faults.

-- 
Posted via http://www.ruby-forum.com/.