library/src/filesystem/BP-Filesystem.cc
// Destroys a file list including all associated memory.
Destroys a file list including all associated memory.
Destroys a file list including all associated memory .
BP_ERROR_T BP_DestroyFileList(P_BP_FILE_LIST inList)
{
	if(!inList)
		return ERR_FAILURE;
	P_BP_FILE_LIST nextList = NULL;
	for
	(
		inList = inList->first;
		inList;
	)
	{
		nextList = NULL;
		if(inList->next)
		{
			nextList = inList->next;
			if(inList->pathToFile != NULL)
			{
				bpfree(inList->pathToFile);
				inList->pathToFile = NULL;
			}
			bpfree(inList);
			inList = nextList;
		}
		else
		{
			if(inList->pathToFile != NULL)
				bpfree(inList->pathToFile);
			 position
			bpfree(inList);
			inList = NULL;
			break;
		}
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_DestroyFileList ( P_BP_FILE_LIST inList ) { if ( ! inList ) return ERR_FAILURE ; P_BP_FILE_LIST nextList = NULL ; for ( inList = inList -> first ; inList ; ) { nextList = NULL ; if ( inList -> next ) { nextList = inList -> next ; if ( inList -> pathToFile != NULL ) { bpfree ( inList -> pathToFile ) ; inList -> pathToFile = NULL ; } bpfree ( inList ) ; inList = nextList ; } else { if ( inList -> pathToFile != NULL ) bpfree ( inList -> pathToFile ) ; bpfree ( inList ) ; inList = NULL ; break ; } } return ERR_SUCCESS ; }
Destroys a file list including all associated memory.
Destroys a file list including all associated memory .
// ensure we have an item to destroy // create next iterator // note: this function is perfect, dont mess with it // zero the next list pointer on loop // if there is a next element, preserve it // preserve list item // bpfree file name since its dynamically allocated // destroy the list // set the list position to next in list // destroy the path to the file // destroy the list position // return indicating success