Skip to content

Commit

Permalink
r.accumulate: Free memory earlier (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
HuidaeCho committed Mar 6, 2020
1 parent a983d8c commit 83f0dd3
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions grass7/raster/r.accumulate/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,17 @@ int main(int argc, char *argv[])
accumulate(&dir_buf, &weight_buf, &accum_buf, done, neg);
}

/* write out buffer to the accumulatoin map if requested */
/* free buffer memory */
for (row = 0; row < rows; row++) {
G_free(done[row]);
if (weight_name)
G_free(weight_buf.map.v[row]);
}
G_free(done);
if (weight_name)
G_free(weight_buf.map.v);

/* write out buffer to the accumulation map if requested */
if (accum_name) {
int accum_fd = Rast_open_new(accum_name, accum_buf.type);
struct History hist;
Expand All @@ -443,16 +453,6 @@ int main(int argc, char *argv[])
Rast_write_history(accum_name, &hist);
}

/* free buffer memory */
for (row = 0; row < rows; row++) {
G_free(done[row]);
if (weight_name)
G_free(weight_buf.map.v[row]);
}
G_free(done);
if (weight_name)
G_free(weight_buf.map.v);

/* delineate stream networks */
if (stream_name) {
if (Vect_open_new(&Map, stream_name, 0) < 0)
Expand Down

0 comments on commit 83f0dd3

Please sign in to comment.