diff options
author | Thomas White <taw@bitwiz.org.uk> | 2011-01-26 17:57:44 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:12 +0100 |
commit | e3a2807bedf1a1a9e25923ee9bc0db653c4c4033 (patch) | |
tree | c8bb22ff1ab2b38e37fa70d545c6bdcc0cf0e7b7 /src/index.c | |
parent | eb24fd94de4e5d59b691acf0b1bfd43de64d66c1 (diff) |
Fix many small memory leaks
Diffstat (limited to 'src/index.c')
-rw-r--r-- | src/index.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/index.c b/src/index.c index ce6021da..6f9b5278 100644 --- a/src/index.c +++ b/src/index.c @@ -162,7 +162,8 @@ void index_pattern(struct image *image, UnitCell *cell, IndexingMethod *indm, } if ( (cellr == CELLR_NONE) || (indm[n] == INDEXING_TEMPLATE) ) { - image->indexed_cell = image->candidate_cells[0]; + image->indexed_cell = cell_new_from_cell( + image->candidate_cells[0]); if ( verbose ) { STATUS("--------------------\n"); STATUS("The indexed cell (matching not" @@ -170,7 +171,7 @@ void index_pattern(struct image *image, UnitCell *cell, IndexingMethod *indm, cell_print(image->indexed_cell); STATUS("--------------------\n"); } - return; + goto done; } for ( i=0; i<image->ncells; i++ ) { @@ -206,6 +207,7 @@ void index_pattern(struct image *image, UnitCell *cell, IndexingMethod *indm, /* Sanity check */ if ( !peak_sanity_check(image, new_cell, 0, 0.1) ) { STATUS("Failed peak sanity check.\n"); + cell_free(new_cell); continue; } @@ -216,6 +218,7 @@ void index_pattern(struct image *image, UnitCell *cell, IndexingMethod *indm, for ( i=0; i<image->ncells; i++ ) { cell_free(image->candidate_cells[i]); + image->candidate_cells[i] = NULL; } /* Move on to the next indexing method */ @@ -225,6 +228,7 @@ void index_pattern(struct image *image, UnitCell *cell, IndexingMethod *indm, done: for ( i=0; i<image->ncells; i++ ) { + /* May free(NULL) if all algorithms were tried */ cell_free(image->candidate_cells[i]); } } |