From: Paul Brannan Date: 2002-08-16T07:24:53+09:00 Subject: Re: Data_Make_Struct Considered Dangerous? On Fri, Aug 16, 2002 at 05:55:16AM +0900, William Djaja Tjokroaminata wrote: > 2) Second, the "danger" in Data_Make_Struct comes from ALLOC and even > from the Data_Wrap_Struct itself, which may invoke the garbage > collector. However, I still do not get the answer why I ever need to > use ALLOC instead of malloc and its derivatives. For example, > ignoring run-out-of-memory problem, a C statement such as If you ignore the out-of-memory situation, then there is no need to use ALLOC. The point of ALLOC is that a) you may want to free memory periodically and b) if you are out of memory, malloc will fail and ALLOC will not. If this is not a problem for you, or if you need to do your own memory allocation that does not involve malloc, then do not use ALLOC. Some of us do have to worry about out-of-memory situations. For these cases, ALLOC makes perfect sense. I have other code that uses operator new to allocate memory for objects in Ruby extensions. In C++, this makes perfect sense. Use whichever method of allocation makes sense in your application. Paul