Added some documentation and added a destroy() function.
This commit is contained in:
parent
0aaf6a24c9
commit
874d264177
|
@ -260,3 +260,40 @@ void CmdLO_AddElement(char*** target, unsigned int* counter, char* element) {
|
||||||
free(old);
|
free(old);
|
||||||
*counter = cnt + 1;
|
*counter = cnt + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CmdLO_Destroy() {
|
||||||
|
// free everything inside the structures and then the whole tree
|
||||||
|
CONode * node = cmdoptions.options;
|
||||||
|
int i = 0;
|
||||||
|
while (node != 0) {
|
||||||
|
if (node->option->optionscount > 0) {
|
||||||
|
i = 0;
|
||||||
|
for (; i < node->option->optionscount; ++i)
|
||||||
|
free(node->option->options[i]);
|
||||||
|
free(node->option->options);
|
||||||
|
}
|
||||||
|
if (node->option->defaultparametercount > 0) {
|
||||||
|
i = 0;
|
||||||
|
for (; i < node->option->defaultparametercount; ++i)
|
||||||
|
free(node->option->defaultparameters[i]);
|
||||||
|
free(node->option->defaultparameters);
|
||||||
|
}
|
||||||
|
if (node->option->possibleparametercount > 0) {
|
||||||
|
i = 0;
|
||||||
|
for (; i < node->option->possibleparametercount; ++i)
|
||||||
|
free(node->option->possibleparametercount[i]);
|
||||||
|
free(node->option->possibleparametercount);
|
||||||
|
}
|
||||||
|
if (node->option->valuecount > 0) {
|
||||||
|
i = 0;
|
||||||
|
for (; i < node->option->valuecount; ++i)
|
||||||
|
free(node->option->values[i]);
|
||||||
|
free(node->option->values);
|
||||||
|
}
|
||||||
|
free(node->option);
|
||||||
|
CONode* old = node;
|
||||||
|
node = node->next;
|
||||||
|
free(old);
|
||||||
|
}
|
||||||
|
cmdoptions.options = 0;
|
||||||
|
}
|
||||||
|
|
|
@ -88,9 +88,23 @@ double CmdLO_GetDouble(char* name);
|
||||||
* This is the 'Do It Yourself' retrieve function.
|
* This is the 'Do It Yourself' retrieve function.
|
||||||
*/
|
*/
|
||||||
int CmdLO_GetAll(char* name, char** values, unsigned int* count);
|
int CmdLO_GetAll(char* name, char** values, unsigned int* count);
|
||||||
|
/**
|
||||||
|
* Get the node with the given name or create a new one with that name.
|
||||||
|
*/
|
||||||
CONode* CmdLO_Create(char* name);
|
CONode* CmdLO_Create(char* name);
|
||||||
|
/**
|
||||||
|
* Just get the node with the given name.
|
||||||
|
*/
|
||||||
CONode* CmdLO_NodeGet(char* name);
|
CONode* CmdLO_NodeGet(char* name);
|
||||||
|
/**
|
||||||
|
* Convenience function to add a string to a string array.
|
||||||
|
*/
|
||||||
void CmdLO_AddElement(char*** target,unsigned int* counter, char* element);
|
void CmdLO_AddElement(char*** target,unsigned int* counter, char* element);
|
||||||
|
/**
|
||||||
|
* Clean up everything, like nothing ever happened...
|
||||||
|
*/
|
||||||
|
void CmdLO_Destroy();
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue