S
s
Regarding the following pseudocode:
<pseudocode>
char *buffer = new char[10];
//put some values in buffer
if( some_condition )
{
char *temp = new char[10];
//put some values in temp
delete[] buffer;
buffer = temp;
temp = NULL;
}
//continue doing stuff with buffer
</pseudocode>
Question:
Is the "temp = NULL;" statement necessary? If it still points to what
it was originally set, will that memory be deallocated when I leave the
scope of that if block?
Thanks,
s
<pseudocode>
char *buffer = new char[10];
//put some values in buffer
if( some_condition )
{
char *temp = new char[10];
//put some values in temp
delete[] buffer;
buffer = temp;
temp = NULL;
}
//continue doing stuff with buffer
</pseudocode>
Question:
Is the "temp = NULL;" statement necessary? If it still points to what
it was originally set, will that memory be deallocated when I leave the
scope of that if block?
Thanks,
s