Skip to content
Snippets Groups Projects
Commit 3c383661 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Fix freed memory error

parent 986ab6d1
Branches
Tags
1 merge request!506Add ParMETIS support
...@@ -734,13 +734,15 @@ static void pick_parmetis(int nodeID, struct space *s, int nregions, ...@@ -734,13 +734,15 @@ static void pick_parmetis(int nodeID, struct space *s, int nregions,
int *newcelllist = NULL; int *newcelllist = NULL;
if ((newcelllist = (int *)malloc(sizeof(int) * ncells)) == NULL) if ((newcelllist = (int *)malloc(sizeof(int) * ncells)) == NULL)
error("Failed to allocate new celllist"); error("Failed to allocate new celllist");
int *remoteids = NULL;
if ((remoteids = (int *)malloc(sizeof(idx_t) * ncells)) == NULL)
error("Failed to allocate new celllist");
for (int k = 0; k < nregions; k++) reqs[k] = MPI_REQUEST_NULL; for (int k = 0; k < nregions; k++) reqs[k] = MPI_REQUEST_NULL;
if (nodeID == 0) { if (nodeID == 0) {
/* Need to accept idx_t, so buffer. */
int *remoteids = NULL;
if ((remoteids = (int *)malloc(sizeof(idx_t) * ncells)) == NULL)
error("Failed to allocate new celllist");
for (int rank = 0, j = 0; rank < nregions; rank++) { for (int rank = 0, j = 0; rank < nregions; rank++) {
int nvt = vtxdist[rank + 1] - vtxdist[rank]; int nvt = vtxdist[rank + 1] - vtxdist[rank];
...@@ -773,8 +775,7 @@ static void pick_parmetis(int nodeID, struct space *s, int nregions, ...@@ -773,8 +775,7 @@ static void pick_parmetis(int nodeID, struct space *s, int nregions,
/* Copy. */ /* Copy. */
for (int k = 0; k < ncells; k++) newcelllist[k] = remoteids[k]; for (int k = 0; k < ncells; k++) newcelllist[k] = remoteids[k];
free(remoteids);
if (remoteids != NULL) free(remoteids);
} else { } else {
res = MPI_Isend(regionid, vtxdist[nodeID + 1] - vtxdist[nodeID], IDX_T, 0, res = MPI_Isend(regionid, vtxdist[nodeID + 1] - vtxdist[nodeID], IDX_T, 0,
...@@ -816,7 +817,6 @@ static void pick_parmetis(int nodeID, struct space *s, int nregions, ...@@ -816,7 +817,6 @@ static void pick_parmetis(int nodeID, struct space *s, int nregions,
/* Clean up. */ /* Clean up. */
free(reqs); free(reqs);
free(stats); free(stats);
free(remoteids);
free(newcelllist); free(newcelllist);
if (weights_v != NULL) free(weights_v); if (weights_v != NULL) free(weights_v);
if (weights_e != NULL) free(weights_e); if (weights_e != NULL) free(weights_e);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment