Author | Message | Time |
---|---|---|
Maddox | [quote author=Kp link=topic=13030.msg131075#msg131075 date=1129386503] 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. [/quote] 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? | November 17, 2005, 5:32 PM |
Kp | [quote author=Maddox link=topic=13030.msg134377#msg134377 date=1132248745][quote author=Kp link=topic=13030.msg131075#msg131075 date=1129386503]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.[/quote]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] 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. | November 18, 2005, 3:03 AM |