Added some documentation and added a destroy() function.

This commit is contained in:
Marcel 2014-03-09 13:35:54 +00:00
parent 0aaf6a24c9
commit 874d264177
2 changed files with 52 additions and 1 deletions

View File

@ -260,3 +260,40 @@ void CmdLO_AddElement(char*** target, unsigned int* counter, char* element) {
free(old);
*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;
}

View File

@ -88,9 +88,23 @@ double CmdLO_GetDouble(char* name);
* This is the 'Do It Yourself' retrieve function.
*/
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);
/**
* Just get the node with the given 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);
/**
* Clean up everything, like nothing ever happened...
*/
void CmdLO_Destroy();
#endif