|
-
July 8th, 1999, 11:57 AM
#1
Using Realloc with the result of New?
I've just come upon something that I had never thought of before: can realloc() be used on a ptr that was assigned by the new opperator? And if so, will the opperator delete function correctly?
-
July 8th, 1999, 12:15 PM
#2
Re: Using Realloc with the result of New?
I can't quote a definate answer for you, but I would strongly caution against doing this even if your compiler will allow it. Write a realloc function that uses new to allocate a larger buffer, memcpy, and delete the original.
Roger C. Scudder Jr.
Annance Consulting
Wayne, Pennsylvania, US
-
July 8th, 1999, 12:23 PM
#3
Re: Using Realloc with the result of New?
The answer is "don't do it". realloc() and new() are different things that are not to be mixed together. The new() calls constructors, while realloc has no idea of objects or constructors.
You can't mix a call to new() with free(), or malloc() with delete(). The same thing goes with new() with realloc()/calloc().
Regards,
Paul McKenzie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|