By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,260 Members | 1,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,260 IT Pros & Developers. It's quick & easy.

realloc in case of new and delete operators

P: n/a
Hi, As you know memory block assigned by malloc can be resized by
realloc with previously assigned data in the memory block intact. How
this to achieve in case
if the memory block is assigned with "new" operator.
thanks crick.
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
free2cric wrote:

Hi, As you know memory block assigned by malloc can be resized by
realloc with previously assigned data in the memory block intact. How
this to achieve in case
if the memory block is assigned with "new" operator.


There is no way to do that with one simple call.

Allocate more memory
copy the old content to the new location
free the old memory

Or simply use a standard contained such as std::vector.
They do all of this automatically for you under the hood.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.