history: fix memory leak
This commit is contained in:
parent
e7ea706157
commit
df2129a1bb
@ -68,7 +68,7 @@ bool CLI_deinit()
|
|||||||
|
|
||||||
FIFOBuffChar_delete(FIFO);
|
FIFOBuffChar_delete(FIFO);
|
||||||
#ifdef HISTORY
|
#ifdef HISTORY
|
||||||
History_deinit(History);
|
History_deinit(History, true);
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,7 @@ int CMDList_add(CMDList_t *list, CMD_t* cmd, char* cmdName)
|
|||||||
read_p = cmd->cmd;
|
read_p = cmd->cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (returnCode == 0)
|
while (returnCode >= 0)
|
||||||
{
|
{
|
||||||
char c = *read_p & (~0x20); // convert to uppercase
|
char c = *read_p & (~0x20); // convert to uppercase
|
||||||
if ((c >= 'A') && (c <= 'Z'))
|
if ((c >= 'A') && (c <= 'Z'))
|
||||||
|
|||||||
@ -19,7 +19,7 @@ History_t* History_init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int History_deinit(History_t* history)
|
int History_deinit(History_t* history, bool freeLines)
|
||||||
{
|
{
|
||||||
// Check if the buffer there is something in the buffer
|
// Check if the buffer there is something in the buffer
|
||||||
if (history->FirstEl_p == NULL)
|
if (history->FirstEl_p == NULL)
|
||||||
@ -29,6 +29,10 @@ int History_deinit(History_t* history)
|
|||||||
while (el != NULL)
|
while (el != NULL)
|
||||||
{
|
{
|
||||||
History_element_t* nextEl = el->nextEl_p;
|
History_element_t* nextEl = el->nextEl_p;
|
||||||
|
if (freeLines)
|
||||||
|
{
|
||||||
|
free(el->line);
|
||||||
|
}
|
||||||
free(el);
|
free(el);
|
||||||
el = nextEl;
|
el = nextEl;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user