1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-12-23 04:43:57 +01:00

Fixed resource leak (fclose)

This commit is contained in:
Anthony Scemama 2021-03-27 19:40:27 +01:00
parent 1feb3a6595
commit c56bc49ddd

View File

@ -56,8 +56,6 @@
#include "trexio_text.h" #include "trexio_text.h"
#define DEBUG printf("%s : line %d\n", __FILE__, __LINE__);
#+end_src #+end_src
@ -267,7 +265,6 @@ $group$_t* trexio_text_read_$group$(trexio_text_t* file) {
if (file_name == NULL) { if (file_name == NULL) {
FREE($group$); FREE($group$);
DEBUG
return NULL; return NULL;
} }
@ -286,8 +283,8 @@ DEBUG
char* buffer = CALLOC(sz,char); char* buffer = CALLOC(sz,char);
if (buffer == NULL) { if (buffer == NULL) {
FREE(file_name); FREE(file_name);
fclose(f);
FREE($group$); FREE($group$);
DEBUG
return NULL; return NULL;
} }
@ -300,8 +297,8 @@ DEBUG
if ((rc != 1) || (strcmp(buffer, "rank_$group_dset$") != 0)) { if ((rc != 1) || (strcmp(buffer, "rank_$group_dset$") != 0)) {
FREE(buffer); FREE(buffer);
FREE(file_name); FREE(file_name);
fclose(f);
FREE($group$); FREE($group$);
DEBUG
return NULL; return NULL;
} }
@ -309,8 +306,8 @@ DEBUG
if (rc != 1) { if (rc != 1) {
FREE(buffer); FREE(buffer);
FREE(file_name); FREE(file_name);
fclose(f);
FREE($group$); FREE($group$);
DEBUG
return NULL; return NULL;
} }
@ -325,8 +322,8 @@ DEBUG
if ((rc != 2) || (strcmp(buffer, "dims_$group_dset$") != 0) || (j!=i)) { if ((rc != 2) || (strcmp(buffer, "dims_$group_dset$") != 0) || (j!=i)) {
FREE(buffer); FREE(buffer);
FREE(file_name); FREE(file_name);
fclose(f);
FREE($group$); FREE($group$);
DEBUG
return NULL; return NULL;
} }
@ -335,8 +332,8 @@ DEBUG
if (rc != 1) { if (rc != 1) {
FREE(buffer); FREE(buffer);
FREE(file_name); FREE(file_name);
fclose(f);
FREE($group$); FREE($group$);
DEBUG
return NULL; return NULL;
} }
@ -353,8 +350,8 @@ DEBUG
if ((rc != 1) || (strcmp(buffer, "$group_num$") != 0)) { if ((rc != 1) || (strcmp(buffer, "$group_num$") != 0)) {
FREE(buffer); FREE(buffer);
FREE(file_name); FREE(file_name);
fclose(f);
FREE($group$); FREE($group$);
DEBUG
return NULL; return NULL;
} }
@ -363,8 +360,8 @@ DEBUG
if (rc != 1) { if (rc != 1) {
FREE(buffer); FREE(buffer);
FREE(file_name); FREE(file_name);
fclose(f);
FREE($group$); FREE($group$);
DEBUG
return NULL; return NULL;
} }
@ -378,8 +375,8 @@ DEBUG
if ($group$->$group_dset$ == NULL) { if ($group$->$group_dset$ == NULL) {
FREE(buffer); FREE(buffer);
FREE(file_name); FREE(file_name);
fclose(f);
FREE($group$); FREE($group$);
DEBUG
return NULL; return NULL;
} }
@ -388,10 +385,10 @@ DEBUG
if ((rc != 1) || (strcmp(buffer, "$group_dset$") != 0)) { if ((rc != 1) || (strcmp(buffer, "$group_dset$") != 0)) {
FREE(buffer); FREE(buffer);
FREE(file_name); FREE(file_name);
fclose(f);
// TODO: free all dsets // TODO: free all dsets
FREE($group$->$group_dset$); FREE($group$->$group_dset$);
FREE($group$); FREE($group$);
DEBUG
return NULL; return NULL;
} }
@ -401,10 +398,10 @@ DEBUG
if (rc != 1) { if (rc != 1) {
FREE(buffer); FREE(buffer);
FREE(file_name); FREE(file_name);
fclose(f);
// TODO: free all dsets // TODO: free all dsets
FREE($group$->$group_dset$); FREE($group$->$group_dset$);
FREE($group$); FREE($group$);
DEBUG
return NULL; return NULL;
} }
} }
@ -427,7 +424,6 @@ DEBUG
// TODO: free all dsets // TODO: free all dsets
FREE($group$->$group_dset$); FREE($group$->$group_dset$);
FREE($group$); FREE($group$);
DEBUG
return NULL; return NULL;
} }