Quote from: Kp on October 15, 2005, 09:28 AM
Actually, malloc was the standard way of allocating memory for a long time before new came along. He should use whichever allocation method is most appropriate for the data type - and always match up the allocation/release types. Typically, I use malloc/realloc/free for any "simple" data type (built-ins + any that I know will never have constructors due to compatibility reasons), since that grants the opportunity to realloc the size up and down as I please without a guaranteed copy. Use new/delete for single instances of non-POD types, and use new[] / delete[] for arrays of non-POD types.
I've used malloc, realloc, and free, but this is C++ and generally you use 'new'. In this case he had use delete on memory allocated with malloc so I suggested he use delete instead. What is so hard to understand?
Quote from: Maddox on November 17, 2005, 11:32 AMQuote from: Kp on October 15, 2005, 09:28 AMActually, malloc was the standard way of allocating memory for a long time before new came along. He should use whichever allocation method is most appropriate for the data type - and always match up the allocation/release types. Typically, I use malloc/realloc/free for any "simple" data type (built-ins + any that I know will never have constructors due to compatibility reasons), since that grants the opportunity to realloc the size up and down as I please without a guaranteed copy. Use new/delete for single instances of non-POD types, and use new[] / delete[] for arrays of non-POD types.
I've used malloc, realloc, and free, but this is C++ and generally you use 'new'. In this case he had use delete on memory allocated with malloc so I suggested he use delete instead. What is so hard to understand?
No, generally I use the most appropriate allocator for the data type I'm working on. I don't tend to release source to the public, so I
know your comments about what I do are speculation. Please refrain from guessing.