fixed memory leaks, added cleanup code, added valgrind scripts to test binaries

This commit is contained in:
Martin Preuss
2023-08-09 17:24:44 +02:00
parent 4701a71986
commit b5916acf79
41 changed files with 991 additions and 170 deletions

View File

@@ -204,6 +204,37 @@ AQH_VALUE *AQH_Storage_GetValueById(const AQH_STORAGE *sto, uint64_t id)
uint32_t AQH_Storage_GetRuntimeFlags(const AQH_STORAGE *sto)
{
return sto?sto->runtimeFlags:0;
}
void AQH_Storage_SetRuntimeFlags(AQH_STORAGE *sto, uint32_t flags)
{
if (sto)
sto->runtimeFlags=flags;
}
void AQH_Storage_AddRuntimeFlags(AQH_STORAGE *sto, uint32_t flags)
{
if (sto)
sto->runtimeFlags|=flags;
}
void AQH_Storage_SubRuntimeFlags(AQH_STORAGE *sto, uint32_t flags)
{
if (sto)
sto->runtimeFlags&=~flags;
}
void AQH_Storage_HandleMqttPublish(AQH_STORAGE *sto, const char *topic, const char *value)
{
/* TODO */
@@ -216,7 +247,10 @@ int AQH_Storage_Init(AQH_STORAGE *sto)
int rv;
rv=GWEN_Directory_GetPath(sto->stateFile,
GWEN_PATH_FLAGS_CHECKROOT | GWEN_PATH_FLAGS_PATHMUSTEXIST | GWEN_PATH_FLAGS_NAMEMUSTEXIST);
GWEN_PATH_FLAGS_CHECKROOT |
GWEN_PATH_FLAGS_PATHMUSTEXIST |
GWEN_PATH_FLAGS_NAMEMUSTEXIST |
GWEN_PATH_FLAGS_VARIABLE);
if (rv==0) {
rv=AQH_Storage_ReadStateFile(sto, sto->stateFile);
if (rv<0) {
@@ -225,7 +259,7 @@ int AQH_Storage_Init(AQH_STORAGE *sto)
}
}
else {
DBG_WARN(AQH_LOGDOMAIN, "State file \"%s\" not available, will try to create it later", sto->stateFile);
DBG_WARN(AQH_LOGDOMAIN, "State file \"%s\" not available, will try to create it later (%d)", sto->stateFile, rv);
}
return 0;
@@ -242,7 +276,7 @@ int AQH_Storage_WriteState(AQH_STORAGE *sto)
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", rv);
return rv;
}
sto->runtimeFlags&=~AQH_STORAGE_RTFLAGS_MODIFIED;
return 0;
}