All pastes #90866 Raw Edit

Miscellany

public cpp v1 · immutable
#90866 ·published 2006-07-18 02:40 UTC
rendered paste body
/********************************************************************************* This is a recursive function which deletes the key pointed to by rootNode_p. It also deletes all* of the subfolders, siblings and lists (longLists and stringLists).********************************************************************************/void DeleteKey(FolderKey_t *rootNode_p){	//base case - if null is passed in we dont do anything	if(rootNode_p != NULL)	{		//recusively delete all the subfolders and siblings		DeleteKey(rootNode_p->m_SubFolder_p);		DeleteKey(rootNode_p->m_Siblings_p);				//delete all the long and string lists referenced by this folderKey		DeleteLongList(rootNode_p->m_LongList_p);		DeleteStringList(rootNode_p->m_StringList_p);				//now that everything this folderKey refrences has been deleted, free the memory for the folderKey		free(rootNode_p);	}}/********************************************************************************* This is a recursive function which deletes the key pointed to by LongList_p. It also deletes all* of the siblings********************************************************************************/void DeleteLongList(LongKey_t *LongList_p){	//base case - if null is passed in we dont do anything	if(LongList_p != NULL)	{		//delete all siblings		DeleteLongList(LongList_p->m_NextLongKey_p);		//with all siblings gone, free the memory for this list		free(LongList_p);	}}/********************************************************************************* This is a recursive function which deletes the key pointed to by StringList_p. It also deletes all* of the siblings********************************************************************************/void DeleteStringList(StringKey_t *StringList_p){	//base case - if null is passed in we dont do anything	if(StringList_p != NULL)	{		//delete all siblings		DeleteStringList(StringList_p->m_NextStringKey_p);		//with all siblings gone, free the memory for this list		free(StringList_p);	}}/********************************************************************************* This function searches the information tree (rootNode_p) for the longKey with path folderPath_p* and name keyName_p and returns it if it exists, otherwise it returns NULL.********************************************************************************/LongKey_t *GetLongKey(FolderKey_t *rootNode_p, const char *folderPath_p, const char *keyName_p){	LongKey_t ret;	FolderKey_t PathFolder;	LongKey_t LongList_p;		ret = null;	PathFolder = GetFolder(rootNode_p, folderPath_p);	LongList_p = PathFolder->m_LongList_p;		while(null != LongList_p)	{		if(0 == strcmp(LongList_p->m_KeyName_p,keyName_p)		{			//Found It!			ret = LongList_p;			break;		}		LongList_p = LongList_p->m_NextLongKey_p;	}		return ret;}/********************************************************************************* This function searches the information tree (rootNode_p) for the stringKey with* path folderPath_p and name keyName_p and returns it if it exists, otherwise it* returns NULL.********************************************************************************/StringKey_t *GetStringKey(FolderKey_t *rootNode_p, const char *folderPath_p, const char *keyName_p){	StringKey_t ret;	FolderKey_t PathFolder;	StringKey_t StringList_p;		ret = null;	PathFolder = GetFolder(rootNode_p, folderPath_p);	StringList_p = PathFolder->m_StringList_p;		while(null != StringList_p)	{		if(0 == strcmp(StringList_p->m_KeyName_p,keyName_p)		{			//Found It!			ret = StringList_p;			break;		}		StringList_p = StringList_p->m_NextStringKey_p;	}		return ret;}