Skip to content

Commit

Permalink
fixed memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Mar 7, 2019
1 parent fc2fc45 commit d85c2b7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/clib/pioc_sc.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,6 @@ PIO_Offset GCDblocksize(int arrlen, const PIO_Offset *arr_in)
/* Check inputs. */
pioassert(arrlen > 0 && arr_in, "invalid input", __FILE__, __LINE__);

/* Allocate arrays. */
if (!(loc_arr = malloc(sizeof(PIO_Offset) * (arrlen - 1))))
return PIO_ENOMEM;
if (!(del_arr = malloc(sizeof(PIO_Offset) * (arrlen - 1))))
return PIO_ENOMEM;

/* Count the number of contiguous blocks in arr_in. If any if
these blocks is of size 1, we are done and can return.
Otherwise numtimes is the number of blocks. */
Expand All @@ -170,6 +164,12 @@ PIO_Offset GCDblocksize(int arrlen, const PIO_Offset *arr_in)
}
}

/* Allocate arrays. */
if (!(loc_arr = malloc(sizeof(PIO_Offset) * (arrlen - 1))))
return PIO_ENOMEM;
if (!(del_arr = malloc(sizeof(PIO_Offset) * (arrlen - 1))))
return PIO_ENOMEM;

/* If numtimes is 0 the all of the data in arr_in is contiguous
* and numblks=1. Not sure why I have three different variables
* here, seems like n,numblks and numtimes could be combined. */
Expand Down

0 comments on commit d85c2b7

Please sign in to comment.