Hi, At Tue, 13 Aug 2002 22:50:08 +0900, William Djaja Tjokroaminata wrote: > 1) NEVER use Data_Make_Struct. Use Data_Wrap_Struct instead. > 2) NEVER use Ruby's ALLOC. Use, at least, C's malloc instead. > > Regarding point 1), because Data_Wrap_Struct will not invoke the gc, it is > safer. Regarding point 2), Ruby's ALLOC may have the same problem as > Data_Wrap_Struct, i.e., we will never know whether the gc will be invoked > at that point or not. Because the corresponding free function is usually > the C's standard free () function anyway (there is no Ruby's FREE > function), probably it is more consistent to use malloc instead of > ALLOC. When we use malloc, we know that the gc will not be invoked and we > can proceed in C as usual, without worrying about the gc trigger and > object states. It sounds strange. Data_Make_Struct() fills the allocated structure with 0 and rb_gc_mark() ignores 0 which is equal to Qfalse. Also, since GC may be invoked while Data_Wrap_Struct() allocates new Data object, your conclusion isn't so meaningful. Additionaly, you can use ruby_xfree for free. -- Nobu Nakada