Главная страница | назад





Article #15543: Farrealloc to grow a block of memory for new _huge

 Question and Answer Database
FAQ543C.txt Farrealloc to grow a block of memory for new _huge
Category :C/C++ Language Issues
Platform :DOS
Product : BC++4.5x BC++5.x TC++Win4.5
Question:
Can I use farrealloc to grow a block of memory for new _huge ?
Answer:
No, DO NOT MIX malloc/realloc/free/farmalloc/farrealloc/farfree with new/delete.
There is no analagous new/delete style of function to realloc or farrealloc.
You will have to do a new _huge of the new size block.
You can do it something like this:
 — If the new block is larger, copy over the old size amount of data
 — Else if it is smaller, copy the new size amount of data.
 — If the allocation fails, return NULL or throw an exception
 — Else delete the old pointer and return the new one.
An alternative is to not fool with new/delete at all and do everything with
farmalloc, farrealloc and farfree.
7/2/98 10:32:32 AM

Last Modified: 01-SEP-99