Access pointer data only if it is not NULL (#809)
This PR solves the GitHub issue #808
This commit is contained in:
parent
2b1dd32d10
commit
79e4ddb5a8
@ -161,10 +161,12 @@ HYPRE_SStructMatrixDestroy( HYPRE_SStructMatrix matrix )
|
|||||||
hypre_SStructPGrid *pgrid;
|
hypre_SStructPGrid *pgrid;
|
||||||
HYPRE_Int nvars;
|
HYPRE_Int nvars;
|
||||||
HYPRE_Int part, var;
|
HYPRE_Int part, var;
|
||||||
HYPRE_MemoryLocation memory_location = hypre_SStructMatrixMemoryLocation(matrix);
|
HYPRE_MemoryLocation memory_location;
|
||||||
|
|
||||||
if (matrix)
|
if (matrix)
|
||||||
{
|
{
|
||||||
|
memory_location = hypre_SStructMatrixMemoryLocation(matrix);
|
||||||
|
|
||||||
hypre_SStructMatrixRefCount(matrix) --;
|
hypre_SStructMatrixRefCount(matrix) --;
|
||||||
if (hypre_SStructMatrixRefCount(matrix) == 0)
|
if (hypre_SStructMatrixRefCount(matrix) == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -79,12 +79,13 @@ HYPRE_SStructVectorDestroy( HYPRE_SStructVector vector )
|
|||||||
hypre_SStructPVector **pvectors;
|
hypre_SStructPVector **pvectors;
|
||||||
HYPRE_Int part;
|
HYPRE_Int part;
|
||||||
HYPRE_Int vector_type;
|
HYPRE_Int vector_type;
|
||||||
HYPRE_MemoryLocation memory_location = hypre_SStructVectorMemoryLocation(vector);
|
HYPRE_MemoryLocation memory_location;
|
||||||
|
|
||||||
/* GEC1002 destroying data indices and data in vector */
|
/* GEC1002 destroying data indices and data in vector */
|
||||||
|
|
||||||
if (vector)
|
if (vector)
|
||||||
{
|
{
|
||||||
|
memory_location = hypre_SStructVectorMemoryLocation(vector);
|
||||||
|
|
||||||
vector_type = hypre_SStructVectorObjectType(vector);
|
vector_type = hypre_SStructVectorObjectType(vector);
|
||||||
hypre_SStructVectorRefCount(vector) --;
|
hypre_SStructVectorRefCount(vector) --;
|
||||||
if (hypre_SStructVectorRefCount(vector) == 0)
|
if (hypre_SStructVectorRefCount(vector) == 0)
|
||||||
|
|||||||
@ -134,67 +134,70 @@ hypre_CommInfoDestroy( hypre_CommInfo *comm_info )
|
|||||||
HYPRE_Int **transforms;
|
HYPRE_Int **transforms;
|
||||||
HYPRE_Int i, size;
|
HYPRE_Int i, size;
|
||||||
|
|
||||||
size = hypre_BoxArrayArraySize(hypre_CommInfoSendBoxes(comm_info));
|
if (comm_info)
|
||||||
hypre_BoxArrayArrayDestroy(hypre_CommInfoSendBoxes(comm_info));
|
|
||||||
processes = hypre_CommInfoSendProcesses(comm_info);
|
|
||||||
for (i = 0; i < size; i++)
|
|
||||||
{
|
|
||||||
hypre_TFree(processes[i], HYPRE_MEMORY_HOST);
|
|
||||||
}
|
|
||||||
hypre_TFree(processes, HYPRE_MEMORY_HOST);
|
|
||||||
rboxnums = hypre_CommInfoSendRBoxnums(comm_info);
|
|
||||||
if (rboxnums != NULL)
|
|
||||||
{
|
{
|
||||||
|
size = hypre_BoxArrayArraySize(hypre_CommInfoSendBoxes(comm_info));
|
||||||
|
hypre_BoxArrayArrayDestroy(hypre_CommInfoSendBoxes(comm_info));
|
||||||
|
processes = hypre_CommInfoSendProcesses(comm_info);
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
hypre_TFree(rboxnums[i], HYPRE_MEMORY_HOST);
|
hypre_TFree(processes[i], HYPRE_MEMORY_HOST);
|
||||||
}
|
}
|
||||||
hypre_TFree(rboxnums, HYPRE_MEMORY_HOST);
|
hypre_TFree(processes, HYPRE_MEMORY_HOST);
|
||||||
}
|
rboxnums = hypre_CommInfoSendRBoxnums(comm_info);
|
||||||
hypre_BoxArrayArrayDestroy(hypre_CommInfoSendRBoxes(comm_info));
|
if (rboxnums != NULL)
|
||||||
transforms = hypre_CommInfoSendTransforms(comm_info);
|
|
||||||
if (transforms != NULL)
|
|
||||||
{
|
|
||||||
for (i = 0; i < size; i++)
|
|
||||||
{
|
{
|
||||||
hypre_TFree(transforms[i], HYPRE_MEMORY_HOST);
|
for (i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
hypre_TFree(rboxnums[i], HYPRE_MEMORY_HOST);
|
||||||
|
}
|
||||||
|
hypre_TFree(rboxnums, HYPRE_MEMORY_HOST);
|
||||||
|
}
|
||||||
|
hypre_BoxArrayArrayDestroy(hypre_CommInfoSendRBoxes(comm_info));
|
||||||
|
transforms = hypre_CommInfoSendTransforms(comm_info);
|
||||||
|
if (transforms != NULL)
|
||||||
|
{
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
hypre_TFree(transforms[i], HYPRE_MEMORY_HOST);
|
||||||
|
}
|
||||||
|
hypre_TFree(transforms, HYPRE_MEMORY_HOST);
|
||||||
}
|
}
|
||||||
hypre_TFree(transforms, HYPRE_MEMORY_HOST);
|
|
||||||
}
|
|
||||||
|
|
||||||
size = hypre_BoxArrayArraySize(hypre_CommInfoRecvBoxes(comm_info));
|
size = hypre_BoxArrayArraySize(hypre_CommInfoRecvBoxes(comm_info));
|
||||||
hypre_BoxArrayArrayDestroy(hypre_CommInfoRecvBoxes(comm_info));
|
hypre_BoxArrayArrayDestroy(hypre_CommInfoRecvBoxes(comm_info));
|
||||||
processes = hypre_CommInfoRecvProcesses(comm_info);
|
processes = hypre_CommInfoRecvProcesses(comm_info);
|
||||||
for (i = 0; i < size; i++)
|
|
||||||
{
|
|
||||||
hypre_TFree(processes[i], HYPRE_MEMORY_HOST);
|
|
||||||
}
|
|
||||||
hypre_TFree(processes, HYPRE_MEMORY_HOST);
|
|
||||||
rboxnums = hypre_CommInfoRecvRBoxnums(comm_info);
|
|
||||||
if (rboxnums != NULL)
|
|
||||||
{
|
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
hypre_TFree(rboxnums[i], HYPRE_MEMORY_HOST);
|
hypre_TFree(processes[i], HYPRE_MEMORY_HOST);
|
||||||
}
|
}
|
||||||
hypre_TFree(rboxnums, HYPRE_MEMORY_HOST);
|
hypre_TFree(processes, HYPRE_MEMORY_HOST);
|
||||||
}
|
rboxnums = hypre_CommInfoRecvRBoxnums(comm_info);
|
||||||
hypre_BoxArrayArrayDestroy(hypre_CommInfoRecvRBoxes(comm_info));
|
if (rboxnums != NULL)
|
||||||
transforms = hypre_CommInfoRecvTransforms(comm_info);
|
|
||||||
if (transforms != NULL)
|
|
||||||
{
|
|
||||||
for (i = 0; i < size; i++)
|
|
||||||
{
|
{
|
||||||
hypre_TFree(transforms[i], HYPRE_MEMORY_HOST);
|
for (i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
hypre_TFree(rboxnums[i], HYPRE_MEMORY_HOST);
|
||||||
|
}
|
||||||
|
hypre_TFree(rboxnums, HYPRE_MEMORY_HOST);
|
||||||
}
|
}
|
||||||
hypre_TFree(transforms, HYPRE_MEMORY_HOST);
|
hypre_BoxArrayArrayDestroy(hypre_CommInfoRecvRBoxes(comm_info));
|
||||||
|
transforms = hypre_CommInfoRecvTransforms(comm_info);
|
||||||
|
if (transforms != NULL)
|
||||||
|
{
|
||||||
|
for (i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
hypre_TFree(transforms[i], HYPRE_MEMORY_HOST);
|
||||||
|
}
|
||||||
|
hypre_TFree(transforms, HYPRE_MEMORY_HOST);
|
||||||
|
}
|
||||||
|
|
||||||
|
hypre_TFree(hypre_CommInfoCoords(comm_info), HYPRE_MEMORY_HOST);
|
||||||
|
hypre_TFree(hypre_CommInfoDirs(comm_info), HYPRE_MEMORY_HOST);
|
||||||
|
|
||||||
|
hypre_TFree(comm_info, HYPRE_MEMORY_HOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
hypre_TFree(hypre_CommInfoCoords(comm_info), HYPRE_MEMORY_HOST);
|
|
||||||
hypre_TFree(hypre_CommInfoDirs(comm_info), HYPRE_MEMORY_HOST);
|
|
||||||
|
|
||||||
hypre_TFree(comm_info, HYPRE_MEMORY_HOST);
|
|
||||||
|
|
||||||
return hypre_error_flag;
|
return hypre_error_flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user