Несмотря на то, что вы написали, для tempRow будет установлено значение NULL, оно не освободит выделенную вами память.Для этого вам нужно
free(tempRow);
tempRow = NULL;
Однако, если вы используете C ++, как предлагают теги, было бы лучше использовать C ++ new / delete
double* tempRow;
tempRow = new double[size];
...
delete [] tempRow;
tempRow = NULL;
, вы даже можете использоватьSTL для управления вашим выделением памяти для вас.
std::vector<double> tempRow(size);
// You can access the data, in a similar way to an array
tempRow[5] = tempRow[4]+tempRow[3];
// If you really need to access the underlying pointer, (To pass to another
// function for example) you can do this. Note that the pointer will be valid
// until the vector is destroyed or modified in certain ways that can cause the
// vector to reallocate its memory. So you can't use this to pass data to a
// function that destroys or takes ownership of the passed in pointer.
fn_requiring_pointer( &temp[0] );
// The memory used in tempRow will get cleaned up automatically when the
// object goes out of scope
//
// If I really need to free up the memory used in it early I can use a swap
// hack. (iirc tempRow.clear() isn't guaranteed to release the memory)
std::vector<double>().swap(tempRow); // Unneeded in most cases.
Также пытаться повторно использовать указатель tempRow для чего-то несвязанного, вероятно, не нужно.Просто создайте новый указатель с другим именем.Многократное использование переменной в нескольких разных целях может затруднить понимание кода позже.