From 3104cf229230151e8ca158144952d474f4b61aa3 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sat, 1 Jun 2013 19:00:01 -0700 Subject: Fix multiple small memory leaks --- libcrystfel/src/cell-utils.c | 11 +++++++++++ libcrystfel/src/dirax.c | 2 ++ libcrystfel/src/mosflm.c | 1 + libcrystfel/src/stream.c | 6 +++++- 4 files changed, 19 insertions(+), 1 deletion(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/cell-utils.c b/libcrystfel/src/cell-utils.c index 8b881178..12443c8d 100644 --- a/libcrystfel/src/cell-utils.c +++ b/libcrystfel/src/cell-utils.c @@ -526,6 +526,9 @@ UnitCell *match_cell(UnitCell *cell_in, UnitCell *template_in, int verbose, &bsx, &bsy, &bsz, &csx, &csy, &csz) ) { ERROR("Couldn't get reciprocal cell for template.\n"); + cell_free(template); + cell_free(cell); + tfn_free(uncentering); return NULL; } @@ -545,6 +548,9 @@ UnitCell *match_cell(UnitCell *cell_in, UnitCell *template_in, int verbose, &bsx, &bsy, &bsz, &csx, &csy, &csz) ) { ERROR("Couldn't get reciprocal cell.\n"); + cell_free(template); + cell_free(cell); + tfn_free(uncentering); return NULL; } @@ -715,9 +721,14 @@ UnitCell *match_cell(UnitCell *cell_in, UnitCell *template_in, int verbose, cell_set_unique_axis(new_cell_trans, cell_get_unique_axis(template_in)); + cell_free(template); + tfn_free(uncentering); + return new_cell_trans; } else { + cell_free(template); + tfn_free(uncentering); return NULL; } } diff --git a/libcrystfel/src/dirax.c b/libcrystfel/src/dirax.c index 99e1accb..55e65fd1 100644 --- a/libcrystfel/src/dirax.c +++ b/libcrystfel/src/dirax.c @@ -242,6 +242,8 @@ static void dirax_parseline(const char *line, struct image *image, dirax->done = 1; dirax->success = 1; } + cell_free(dirax->cur_cell); + dirax->cur_cell = NULL; return; diff --git a/libcrystfel/src/mosflm.c b/libcrystfel/src/mosflm.c index c92ef343..162299b7 100644 --- a/libcrystfel/src/mosflm.c +++ b/libcrystfel/src/mosflm.c @@ -519,6 +519,7 @@ static void mosflm_send_next(struct image *image, struct mosflm_data *mosflm) symm = spacegroup_for_lattice(mosflm->mp->template); snprintf(tmp, 255, "SYMM %s\n", symm); + free(symm); mosflm_sendline(tmp, mosflm); } else { diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c index 5782bb82..91f644fa 100644 --- a/libcrystfel/src/stream.c +++ b/libcrystfel/src/stream.c @@ -203,11 +203,15 @@ void write_chunk(Stream *st, struct image *i, struct hdfile *hdfile, int include_peaks, int include_reflections) { int j; + char *indexer; fprintf(st->fh, CHUNK_START_MARKER"\n"); fprintf(st->fh, "Image filename: %s\n", i->filename); - fprintf(st->fh, "indexed_by = %s\n", indexer_str(i->indexed_by)); + + indexer = indexer_str(i->indexed_by); + fprintf(st->fh, "indexed_by = %s\n", indexer); + free(indexer); if ( i->det != NULL ) { -- cgit v1.2.3