The negative effect of the "re-newing" is that you lose the pointer to the free-store memory originally allocated. It will remain occupied throughout the rest of your program, without any chance to reclaim it.
Of course, you may have some other pointer pointing to the memory, but that would be a very strange and unnecessarily complex piece of code.
Avoid all those problems by using std::vector
instead of new[]
.
tc1 = new TCHAR[size1];
tc1[size1] = { L'\0' };
In addition to the memory leak, this is undefined behaviour because size1
is one past the last valid index.
Here's a std::vector
example:
std::vector<TCHAR> tc1(1);
// later:
//resize TCHARs
tc1.resize(size1);
tc1[size1 - 1] = L'\0';
Perhaps even std::string
or std::wstring
is sufficient for your needs.