From: Charles Mills Date: 2005-07-22T07:55:57+09:00 Subject: Re: C extension makes things slower Mauricio Fern�ndez wrote: > On Fri, Jul 22, 2005 at 05:40:57AM +0900, Phil Tomson wrote: > > Oh, for the sake of complete documentation in case someone has similar > > questions in the future: > [...] > > Just one minor simplification (also, for the record): > > > static void aco_point_free(void* p){ > > free(p); > > } > > static VALUE aco_point_alloc(VALUE klass) { > > VALUE object; > > ACO_Point_Struct* point = (ACO_Point_Struct*)malloc(sizeof( > > ACO_Point_Struct)); > > object = Data_Wrap_Struct(klass,0,aco_point_free,point); > ============== > -1 > This way, free() will be used (and you hence need no aco_point_free > function). > > -- > Mauricio Fernandez Unless you want to make the optimization I did and use the free function as a way of determining what kind of struct is in your T_DATA wrapper. -Charlie