aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-10-22 17:50:37 +0200
committerThomas White <taw@physics.org>2014-10-23 17:02:32 +0200
commit1a37de5cce5c2df83e37fb189409659299594b1b (patch)
treedeb3e7c3b8b661c07aa2a4a4a663c97081d63b05
parent8bdd03533aefabfe13259eb6e9b585420b4ed984 (diff)
Fix a load of memory leaks
-rw-r--r--libcrystfel/src/detector.c1
-rw-r--r--libcrystfel/src/dirax.c2
-rw-r--r--libcrystfel/src/events.c11
-rw-r--r--libcrystfel/src/events.h2
-rw-r--r--libcrystfel/src/integration.c1
-rw-r--r--libcrystfel/src/stream.c3
-rw-r--r--src/im-sandbox.c8
-rw-r--r--src/indexamajig.c2
-rw-r--r--src/process_image.c7
9 files changed, 20 insertions, 17 deletions
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; i<det->n_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; di<hsd->num_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);
}
diff --git a/src/im-sandbox.c b/src/im-sandbox.c
index 45a058ba..6970a14f 100644
--- a/src/im-sandbox.c
+++ b/src/im-sandbox.c
@@ -476,10 +476,10 @@ static void run_work(const struct index_args *iargs,
ERROR("write P0\n");
}
- free_filename_plus_event(pargs.filename_p_e);
-
}
+ free_filename_plus_event(pargs.filename_p_e);
+
}
free(bd.line);
@@ -780,7 +780,7 @@ static void start_worker_process(struct sandbox *sb, int slot)
free(sb->filename_pipes);
free(sb->result_fhs);
free(sb->pids);
- /* Also prefix, use_this_one_instead and fh */
+ /* Also prefix, tempdir, */
/* Child process gets the 'read' end of the filename
* pipe, and the 'write' end of the result pipe. */
@@ -795,6 +795,8 @@ static void start_worker_process(struct sandbox *sb, int slot)
//close(filename_pipe[0]);
close(result_pipe[1]);
+ free(sb);
+
exit(0);
}
diff --git a/src/indexamajig.c b/src/indexamajig.c
index b139f299..cb4ee084 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -679,6 +679,8 @@ int main(int argc, char *argv[])
free(prefix);
free(tempdir);
free_detector_geometry(iargs.det);
+ close_stream(st);
+ cleanup_indexing(indm, ipriv);
return 0;
}
diff --git a/src/process_image.c b/src/process_image.c
index 68708fd7..807facd9 100644
--- a/src/process_image.c
+++ b/src/process_image.c
@@ -164,12 +164,6 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs,
mark_resolution_range_as_bad(&image, iargs->highres, +INFINITY);
- hdfile = hdfile_open(image.filename);
- if ( hdfile == NULL ) {
- ERROR("Couldn't open file %s.\n", image.filename);
- return;
- }
-
switch ( iargs->peaks ) {
case PEAK_HDF5:
@@ -224,6 +218,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs,
hdfile_close(hdfile);
return;
}
+ free(rn);
pargs->n_crystals = image.n_crystals;
for ( i=0; i<image.n_crystals; i++ ) {