On Wed, 09 Apr 2003 09:10:36 +0900, Mauricio FernŠŌdez wrote:
>> 
>> Objects::~Objects() {
>> 	rb_gc_unregister_address(&objects);
>> }
>> 
>> Unregistering all objects: Is this dtor sufficent ???
>> 
>> Should I manualy erase each element first ???
>> or is this unnecessary?
> 
> If I got it right, not. The GC won't mark them, and they will be swept
> away.

Me asking many silly questions and you answered them,  
thanks 1000 times :-)


Finaly my class looks like this..



Objects::Objects() {
	objects = rb_ary_new();
	rb_gc_register_address(&objects);
}

Objects::~Objects() {
	// dispose array and flush all elements
	rb_gc_unregister_address(&objects);
	/*      
	mass destrurction.
	GC can no longer can mark the elements in
	the Array and therefore they will all get swept.
	*/
}

void Objects::Register(VALUE object) {
	rb_ary_push(objects, object);
}

void Objects::Unregister(VALUE object) {
	rb_ary_delete(objects, object);
}