[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 29f8b20 16/19: Table and Arithmetic: corrected
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 29f8b20 16/19: Table and Arithmetic: corrected some memory leaks |
Date: |
Sun, 14 Nov 2021 20:41:00 -0500 (EST) |
branch: master
commit 29f8b205493bbcfdab97f206cc7e86e04a2e2f37
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Table and Arithmetic: corrected some memory leaks
Until now, the Table and Arithmetic programs had some memory leaks (not
freeing some allocated space by the time the program finished). Although
they were very minor, it was important to find and fix them.
With this commit they have been freed at the end of the respective program.
---
bin/arithmetic/ui.c | 1 +
bin/table/ui.c | 3 +++
lib/fits.c | 13 +++++++------
lib/options.c | 14 +++++++-------
4 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/bin/arithmetic/ui.c b/bin/arithmetic/ui.c
index 80d2874..35f4b82 100644
--- a/bin/arithmetic/ui.c
+++ b/bin/arithmetic/ui.c
@@ -509,6 +509,7 @@ freeandreport(struct arithmeticparams *p, struct timeval
*t1)
{
/* Free the simple strings. */
free(p->cp.output);
+ if(p->wcshdu) free(p->wcshdu);
if(p->globalhdu) free(p->globalhdu);
/* If there are any remaining HDUs in the hdus linked list, then
diff --git a/bin/table/ui.c b/bin/table/ui.c
index f1aa8b8..aa07616 100644
--- a/bin/table/ui.c
+++ b/bin/table/ui.c
@@ -1304,9 +1304,12 @@ ui_free_report(struct tableparams *p)
free(p->cp.output);
ui_outcols_free(p->outcols);
gal_list_data_free(p->table);
+ if(p->wcshdu) free(p->wcshdu);
gal_list_str_free(p->columns, 1);
if(p->colarray) free(p->colarray);
gal_list_data_free(p->colmetadata);
+ gal_list_str_free(p->catcolumnhdu, 1);
+ gal_list_str_free(p->catcolumnfile, 1);
/* If a random number generator was allocated, free it. */
if(p->rng) gsl_rng_free(p->rng);
diff --git a/lib/fits.c b/lib/fits.c
index 93e2e7d..d61fc9d 100644
--- a/lib/fits.c
+++ b/lib/fits.c
@@ -3847,8 +3847,8 @@ gal_fits_tab_write(gal_data_t *cols, gal_list_str_t
*comments,
gal_data_t *col;
size_t i, numrows=-1;
gal_list_str_t *strt;
- char **ttype, **tform, **tunit;
int tbltype, numcols=0, status=0;
+ char **ttype, **tform, **tunit, **strarr;
/* Make sure all the input columns have the same number of elements */
for(col=cols; col!=NULL; col=col->next)
@@ -3918,11 +3918,12 @@ gal_fits_tab_write(gal_data_t *cols, gal_list_str_t
*comments,
i+1, 1, 1, col->size, col->array, blank, &status);
gal_fits_io_error(status, NULL);
- /* Clean up and Increment the column counter. Note that unlike
- reading a column from a table (in 'fits_tab_read_onecol'), the
- 'blank' value for strings here is directly the string, not a
- pointer to a string. */
- if(blank) free(blank);
+ /* Clean up and Increment the column counter. */
+ if(blank)
+ {
+ if(col->type==GAL_TYPE_STRING) {strarr=blank; free(strarr[0]);}
+ free(blank); blank=NULL;
+ }
++i;
}
diff --git a/lib/options.c b/lib/options.c
index 5cdb50a..61115f6 100644
--- a/lib/options.c
+++ b/lib/options.c
@@ -1821,13 +1821,13 @@ gal_options_read_check(struct argp_option *option, char
*arg, char *filename,
" - It contains non-numerical characters.\n"
" - It is negative, but the expected value is "
"positive.\n"
- " - It is floating point, but the expected value "
- "is an integer.\n"
- " - The previous option required a value, but you "
- "forgot to give it one, so the next option's "
- "name(+value, if there are no spaces between them) "
- "is read as the value of the previous option.", arg,
- option->name);
+ " - It is floating point, but the expected "
+ "value is an integer.\n"
+ " - The previous option required a value, but "
+ "you forgot to give it one, so the next option's "
+ "name(+value, if there are no spaces between "
+ "them) is read as the value of the previous "
+ "option.", arg, option->name);
/* Do a sanity check on the value. */
options_sanity_check(option, arg, filename, lineno);
- [gnuastro-commits] master e04f4ac 03/19: First implementation of k-d tree matching, not complete, (continued)
- [gnuastro-commits] master e04f4ac 03/19: First implementation of k-d tree matching, not complete, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 20ad77d 07/19: Final output for kdtree matching, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 7354e33 09/19: Library (match.h): match_coordinate_ replaced by match_sort_based_, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 03d1a25 15/19: Library (fits.h): corrected segmentation fault in parallel reading, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 336ddee 04/19: Error in `match_kdtree_worker` in lib/match.c, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 2877acb 05/19: Added fits files for testing in `during-dev-test-data`, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 48d760d 12/19: Library (match.h): k-d tree method discards regions with no overlap, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master d0b19b8 10/19: Match: make check script for k-d tree matching now executable, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 095c788 13/19: Match: matched rows aren't permuted, but new column allocated, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 9e258a8 14/19: Library (fits.h): reading table columns now done in parallel, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 29f8b20 16/19: Table and Arithmetic: corrected some memory leaks,
Mohammad Akhlaghi <=
- [gnuastro-commits] master 8b17675 06/19: Corrected segmentation fault, included aperture, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master a7bfa5b 11/19: Match: k-d tree matching UI fixed, to do: finalizing docs and tests, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master f5d7d1a 19/19: Match: added tests, completed docs of new k-d tree based matching, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 6f7ff61 08/19: Library (match.h): Using the old infra-structure for double-matches, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 68823e3 17/19: Library (fits.h): correctly reading columns of 0 width/repeat, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master a6b838c 18/19: Match: script to generate debugging input taken in bin/match/, Mohammad Akhlaghi, 2021/11/14