diff --git a/src/sstruct_mv/HYPRE_sstruct_matrix.c b/src/sstruct_mv/HYPRE_sstruct_matrix.c index a31d21e52..3171fcf50 100644 --- a/src/sstruct_mv/HYPRE_sstruct_matrix.c +++ b/src/sstruct_mv/HYPRE_sstruct_matrix.c @@ -161,10 +161,12 @@ HYPRE_SStructMatrixDestroy( HYPRE_SStructMatrix matrix ) hypre_SStructPGrid *pgrid; HYPRE_Int nvars; HYPRE_Int part, var; - HYPRE_MemoryLocation memory_location = hypre_SStructMatrixMemoryLocation(matrix); + HYPRE_MemoryLocation memory_location; if (matrix) { + memory_location = hypre_SStructMatrixMemoryLocation(matrix); + hypre_SStructMatrixRefCount(matrix) --; if (hypre_SStructMatrixRefCount(matrix) == 0) { diff --git a/src/sstruct_mv/HYPRE_sstruct_vector.c b/src/sstruct_mv/HYPRE_sstruct_vector.c index 21ad864f7..cbbf88a10 100644 --- a/src/sstruct_mv/HYPRE_sstruct_vector.c +++ b/src/sstruct_mv/HYPRE_sstruct_vector.c @@ -79,12 +79,13 @@ HYPRE_SStructVectorDestroy( HYPRE_SStructVector vector ) hypre_SStructPVector **pvectors; HYPRE_Int part; HYPRE_Int vector_type; - HYPRE_MemoryLocation memory_location = hypre_SStructVectorMemoryLocation(vector); + HYPRE_MemoryLocation memory_location; /* GEC1002 destroying data indices and data in vector */ - if (vector) { + memory_location = hypre_SStructVectorMemoryLocation(vector); + vector_type = hypre_SStructVectorObjectType(vector); hypre_SStructVectorRefCount(vector) --; if (hypre_SStructVectorRefCount(vector) == 0) diff --git a/src/struct_mv/communication_info.c b/src/struct_mv/communication_info.c index e1aee9934..60eb4b0a6 100644 --- a/src/struct_mv/communication_info.c +++ b/src/struct_mv/communication_info.c @@ -134,67 +134,70 @@ hypre_CommInfoDestroy( hypre_CommInfo *comm_info ) HYPRE_Int **transforms; HYPRE_Int i, size; - size = hypre_BoxArrayArraySize(hypre_CommInfoSendBoxes(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) + if (comm_info) { + size = hypre_BoxArrayArraySize(hypre_CommInfoSendBoxes(comm_info)); + hypre_BoxArrayArrayDestroy(hypre_CommInfoSendBoxes(comm_info)); + processes = hypre_CommInfoSendProcesses(comm_info); 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_BoxArrayArrayDestroy(hypre_CommInfoSendRBoxes(comm_info)); - transforms = hypre_CommInfoSendTransforms(comm_info); - if (transforms != NULL) - { - for (i = 0; i < size; i++) + hypre_TFree(processes, HYPRE_MEMORY_HOST); + rboxnums = hypre_CommInfoSendRBoxnums(comm_info); + if (rboxnums != NULL) { - 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)); - hypre_BoxArrayArrayDestroy(hypre_CommInfoRecvBoxes(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) - { + size = hypre_BoxArrayArraySize(hypre_CommInfoRecvBoxes(comm_info)); + hypre_BoxArrayArrayDestroy(hypre_CommInfoRecvBoxes(comm_info)); + processes = hypre_CommInfoRecvProcesses(comm_info); 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_BoxArrayArrayDestroy(hypre_CommInfoRecvRBoxes(comm_info)); - transforms = hypre_CommInfoRecvTransforms(comm_info); - if (transforms != NULL) - { - for (i = 0; i < size; i++) + hypre_TFree(processes, HYPRE_MEMORY_HOST); + rboxnums = hypre_CommInfoRecvRBoxnums(comm_info); + if (rboxnums != NULL) { - 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; }