zeroize pointers after freeing memory

This commit is contained in:
dqueteschiner
2015-03-25 09:24:31 +01:00
parent 3fbfa12318
commit 4c2d7531d4

View File

@ -91,7 +91,8 @@ twoWayMPI::twoWayMPI
if (liggghts == 1) lmp = new LAMMPS_NS::LAMMPS(0,NULL,comm_liggghts);
MPI_Bcast(&n,1,MPI_INT,0,MPI_COMM_WORLD);
if (n > 0) {
if (n > 0)
{
MPI_Bcast(liggghtsPathChar,n,MPI_CHAR,0,MPI_COMM_WORLD);
if (liggghts == 1) lmp->input->file(liggghtsPathChar);
}
@ -115,7 +116,7 @@ void twoWayMPI::getData
word name,
word type,
double ** const& field,
label step
label /*step*/
) const
{
data_liggghts_to_of(name.c_str(), type.c_str(), lmp, (void*&) field, "double");
@ -126,7 +127,7 @@ void twoWayMPI::getData
word name,
word type,
int ** const& field,
label step
label /*step*/
) const
{
data_liggghts_to_of(name.c_str(), type.c_str(), lmp, (void*&) field, "int");
@ -179,6 +180,7 @@ void Foam::twoWayMPI::destroy(double** array,int len) const
free(array[i]);
free(array);
array = NULL;
}
//============
@ -207,6 +209,7 @@ void Foam::twoWayMPI::allocateArray
char* charLength= const_cast<char*> (length);
allocate_external_int(array, width,charLength,initVal,lmp);
}
void Foam::twoWayMPI::destroy(int** array,int len) const
{
if (array == NULL) return;
@ -216,6 +219,7 @@ void Foam::twoWayMPI::destroy(int** array,int len) const
free(array[i]);
free(array);
array = NULL;
}
//============
// int *
@ -223,6 +227,7 @@ void Foam::twoWayMPI::destroy(int* array) const
{
if (array == NULL) return;
free(array);
array = NULL;
}
//============
// double *
@ -230,6 +235,7 @@ void Foam::twoWayMPI::destroy(double* array) const
{
if (array == NULL) return;
free(array);
array = NULL;
}
//============