From 6d5dc06446eeabea8cbc6edf66682d299f5148cb Mon Sep 17 00:00:00 2001 From: Patrick Vogler Date: Mon, 28 Oct 2024 11:04:18 +0100 Subject: [PATCH] Modified eas3 interface to decouple it from the command line tool. --- include/interfaces/reader/eas3.h | 12 +++++++++ src/interfaces/reader/eas3.c | 44 +++++++++++++++++++++++--------- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/include/interfaces/reader/eas3.h b/include/interfaces/reader/eas3.h index 00686f9..c7d647b 100644 --- a/include/interfaces/reader/eas3.h +++ b/include/interfaces/reader/eas3.h @@ -347,6 +347,18 @@ || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || || || \************************************************************************************************************/ + /*----------------------------------------------------------------------------------------------------------*\ + ! ! + ! DESCRIPTION: ! + ! ------------ ! + ! This function deallocates the data structure used to store an numerical dataset ! + ! and can be called if an error occurs or once the data is no longer needed is to be closed. ! + ! The deallocation will be carried out down to the structure levels that have been allocated. ! + ! ! + \*----------------------------------------------------------------------------------------------------------*/ + void + eas3_free_data(eas3_data* data); + /*----------------------------------------------------------------------------------------------------------*\ ! FUNCTION NAME: bwc_data* read_eas3(const char* const filename) ! ! -------------- ! diff --git a/src/interfaces/reader/eas3.c b/src/interfaces/reader/eas3.c index baacce0..7581118 100644 --- a/src/interfaces/reader/eas3.c +++ b/src/interfaces/reader/eas3.c @@ -76,7 +76,25 @@ #include #include "eas3.h" -#include "bwccmdl.h" + + +/************************************************************************************************************\ +|| _ _ ____ ____ ____ ____ ____ || +|| |\/| |__| | |__/ | | [__ || +|| | | | | |___ | \ |__| ___] || +|| || +\************************************************************************************************************/ +#define MEMERROR "o##########################################################o\n"\ + "| ERROR: Out of memory |\n"\ + "o##########################################################o\n" + +#define RDERROR "o##########################################################o\n"\ + "| ERROR: Invalid Number of Bytes Read from File. |\n"\ + "o##########################################################o\n" + +#define WRTERROR "o##########################################################o\n"\ + "| ERROR: Invalid Number of Bytes Written to File. |\n"\ + "o##########################################################o\n" /************************************************************************************************************\ || ___ ____ _ _ _ ____ ___ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || @@ -213,18 +231,20 @@ endian_conversion(void *value, void eas3_free_data(eas3_data* data) { - if(data) + if(data != NULL) { - //if(data->aux) - //{ - //free(data->aux->memory); - //data->aux->access = NULL; - //data->aux->position = 0; - //data->aux->size = 0; - // TODO: remove - //data->aux->L = 0; - //} - //free(data->aux); + if (data->param_names != NULL) + free(data->param_names); + + if (data->field.d != NULL) + free(data->field.d); + + if (data->field.f != NULL) + free(data->field.f); + + if(data->aux.ptr != NULL) + free(data->aux.ptr); + free(data); } }