- config file parser dynamically allocates linebuffer to allow multithreaded applications (#484)

pull/487/head
Michael Zillgith 2 years ago
parent e7c2e37ad4
commit aacf853876

@ -31,8 +31,6 @@
#define READ_BUFFER_MAX_SIZE 1024
static uint8_t lineBuffer[READ_BUFFER_MAX_SIZE];
static int
readLine(FileHandle fileHandle, uint8_t* buffer, int maxSize)
{
@ -118,6 +116,11 @@ ConfigFileParser_createModelFromConfigFileEx(const char* filename)
IedModel*
ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
{
uint8_t* lineBuffer = (uint8_t*)GLOBAL_MALLOC(READ_BUFFER_MAX_SIZE);
if (lineBuffer == NULL)
goto exit_error;
int bytesRead = 1;
bool stateInModel = false;
@ -541,8 +544,6 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
else
goto exit_error;
}
}
else {
if (StringUtils_startsWith((char*) lineBuffer, "MODEL{")) {
@ -564,14 +565,18 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
}
}
GLOBAL_FREEMEM(lineBuffer);
return model;
exit_error:
GLOBAL_FREEMEM(lineBuffer);
if (DEBUG_IED_SERVER)
printf("IED_SERVER: error parsing line %i (indentation level = %i)\n", currentLine, indendation);
IedModel_destroy(model);
return NULL;
}

Loading…
Cancel
Save