new / calloc
which is better: new or calloc? performance! i use c!
why dont get all the post to the forum?
''new'' call the object''s constructor if available, malloc don''t (neither do calloc I think since C is not OO).
They should be exactly the same althought i expect that new may use up a bit more memory, keeping track of what you''ve new''d.
I personally use alloc because i''m used to it, i know if i start using new half way through a project i''ll keep forgetting to delete(?) them. Then again it does seem like a far neater option.
I personally use alloc because i''m used to it, i know if i start using new half way through a project i''ll keep forgetting to delete(?) them. Then again it does seem like a far neater option.
The calloc function is just like malloc except that it zero''s out the memory at the same time (this is unneeded most of the time, and lowers the speed). If you''re using C++ just stick with new and delete.
Neither is C++. C++ just has added capabilities for working in an OO paradigm. Therefore, C++ is multiparadigm, not OO. OO code is still very possible in C (look at GTK+).
[Resist Windows XP''s Invasive Production Activation Technology!]
quote:Original post by Prosper/LOADED
since C is not OO
Neither is C++. C++ just has added capabilities for working in an OO paradigm. Therefore, C++ is multiparadigm, not OO. OO code is still very possible in C (look at GTK+).
[Resist Windows XP''s Invasive Production Activation Technology!]
quote:
I personally use alloc because i'm used to it, i know if i start using new half way through a project i'll keep forgetting to delete(?) them. Then again it does seem like a far neater option.
Doesn't you need to call free after calling malloc?
Edited by - hewhay on January 13, 2002 4:27:04 PM
quote:Original post by zipless
They should be exactly the same althought i expect that new may use up a bit more memory, keeping track of what you''ve new''d.
So does malloc().
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement