From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-05-18T23:10:29+09:00 Subject: Re: ruby garbage collection On Sun, 18 May 2003 23:48:28 +0900, Gaffer wrote: > so i didnt know you could override the singleton method new for a class, to > do the Data_Make_Struct, Yeah its a bastard :-) > so i was wrapping an outer 'husk' object with a member variable @data which > was pointing to a Data_Wrap_Struct around my c++ object created with new Yes.. My alloc/free looks something like this (ruby-1.8.0) void Free(Klass *p) { delete p; } VALUE Alloc(VALUE self) { Klass* p = new Klass(); return Data_Wrap_Struct(self, 0, Free, p); } void KlassInit() { VALUE h = rb_define_class("Klass", rb_cObject); rb_define_alloc_func(h, Alloc); } -- Simon Strandgaard