From 1a37de5cce5c2df83e37fb189409659299594b1b Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 22 Oct 2014 17:50:37 +0200 Subject: Fix a load of memory leaks --- libcrystfel/src/detector.c | 1 + libcrystfel/src/dirax.c | 2 ++ libcrystfel/src/events.c | 11 ++++------- libcrystfel/src/events.h | 2 +- libcrystfel/src/integration.c | 1 + libcrystfel/src/stream.c | 3 +++ 6 files changed, 12 insertions(+), 8 deletions(-) (limited to 'libcrystfel/src') diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c index 4a202f2e..683fdd49 100644 --- a/libcrystfel/src/detector.c +++ b/libcrystfel/src/detector.c @@ -1333,6 +1333,7 @@ void free_detector_geometry(struct detector *det) for ( i=0; in_panels; i++ ) { free(det->panels[i].clen_from); + free_dim_structure(det->panels[i].dim_structure); } free(det->panels); diff --git a/libcrystfel/src/dirax.c b/libcrystfel/src/dirax.c index 0a137784..a48cf2e8 100644 --- a/libcrystfel/src/dirax.c +++ b/libcrystfel/src/dirax.c @@ -255,6 +255,8 @@ static void dirax_parseline(const char *line, struct image *image, dirax->success = 1; } + cell_free(cell); + return; } diff --git a/libcrystfel/src/events.c b/libcrystfel/src/events.c index 6e52f6cd..19d69b81 100644 --- a/libcrystfel/src/events.c +++ b/libcrystfel/src/events.c @@ -238,12 +238,13 @@ void free_event_list(struct event_list *el) void free_filename_plus_event(struct filename_plus_event *fpe) { - free(fpe->filename); if ( fpe->ev != NULL ) { free_event(fpe->ev); } + + free(fpe); } @@ -622,12 +623,8 @@ struct dim_structure *default_dim_structure() void free_dim_structure(struct dim_structure *hsd) { - int di; - - for ( di=0; dinum_dims; di++ ) { - free (hsd->dims); - free (hsd); - } + free(hsd->dims); + free(hsd); } diff --git a/libcrystfel/src/events.h b/libcrystfel/src/events.h index e6e5d840..ee47c5a5 100644 --- a/libcrystfel/src/events.h +++ b/libcrystfel/src/events.h @@ -103,6 +103,6 @@ extern int set_dim_structure_entry(struct dim_structure *hsd, const char *string_dim, const char *val_string); extern void free_dim_structure_entry(struct dim_structure *hsd); - +extern void free_dim_structure(struct dim_structure *hsd); #endif /* EVENTS_H */ diff --git a/libcrystfel/src/integration.c b/libcrystfel/src/integration.c index 34bde83a..55adf287 100644 --- a/libcrystfel/src/integration.c +++ b/libcrystfel/src/integration.c @@ -641,6 +641,7 @@ static void delete_box(struct intcontext *ic, struct peak_box *bx) } free(bx->bm); + gsl_matrix_free(bx->bgm); memmove(&ic->boxes[i], &ic->boxes[i+1], (ic->n_boxes-i-1)*sizeof(struct peak_box)); diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c index 519a1ca9..c1b32a4f 100644 --- a/libcrystfel/src/stream.c +++ b/libcrystfel/src/stream.c @@ -1304,6 +1304,9 @@ void write_geometry_file(Stream *st, const char *geom_filename) { rval = fgets(line, 1023, geom_fh); fputs(line, st->fh); } while ( rval != NULL ); + + fclose(geom_fh); + fprintf(st->fh, GEOM_END_MARKER"\n"); fflush(st->fh); } -- cgit v1.2.3