Advertisement

delete && new || realloc( ) ??

Started by April 14, 2003 07:44 AM
4 comments, last by James Trotter 21 years, 10 months ago
What is the best/fastest? First deleting and then allocating with new, or just reallocating the space with realloc()?
Oh, and btw, can I use realloc with new/delete? Or is there another operator?
Advertisement
I''m sorry to trouble you all, but I should really just google for it before I ask... Well, this time I googled for the answer right after I asked the question here, and found the answer right away!

I''ll try loking a little next time ...
Ok, I should probably google as well but I''m just curious, does realloc work with new/delete?
"If all else fails, lower your standards."
Oh, and btw, can I use realloc with new/delete?

Not in the way you are thinking. STL containers are usually the answer.

Or is there another operator?

Placement new. Deep magic.




[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
New/delete are a C++ bunch. Realloc is left over from the old days of C. Your question should be "what''s faster, realloc or free/malloc". By the way, if you feel you need to realloc you might want to implement some sort of a special memory management technique.

This topic is closed to new replies.

Advertisement