Reallocating memory via "new" in C++
- by BSchlinker
Quick question regarding memory management in C++
If I do the following operation:
pointer = new char [strlen(someinput_input)+1];
And then perform it again, with perhaps a different result being returned from strlen(someinput_input).
Does this result in memory being left allocated from the previous "new" statement? IE, is each new statement receiving another block of HEAP memory from the OS, or is it simply reallocating?
Assuming I do a final delete pointer[]; will that deallocate any and all memory that I ever allocated via new to that pointer?
Thanks