Example #1
0
/**
 *	@public
 *	@brief	Destroys an FF_IOMAN object, and frees all assigned memory.
 *
 *	@param	pIoman	Pointer to an FF_IOMAN object, as returned from FF_CreateIOMAN.
 *
 *	@return	FF_ERR_NONE on sucess, or a documented error code on failure. (FF_ERR_NULL_POINTER)
 *
 **/
FF_ERROR FF_DestroyIOMAN(FF_IOMAN *pIoman) {

#ifdef FF_HASH_CACHE
	FF_T_UINT32 i;
#endif

	// Ensure no NULL pointer was provided.
	if(!pIoman) {
		return FF_ERR_NULL_POINTER | FF_DESTROYIOMAN;
	}

	// Ensure pPartition pointer was allocated.
	if((pIoman->MemAllocation & FF_IOMAN_ALLOC_PART)) {
		FF_FREE(pIoman->pPartition);
	}

	// Ensure pBlkDevice pointer was allocated.
	if((pIoman->MemAllocation & FF_IOMAN_ALLOC_BLKDEV)) {
		FF_FREE(pIoman->pBlkDevice);
	}

	// Ensure pBuffers pointer was allocated.
	if((pIoman->MemAllocation & FF_IOMAN_ALLOC_BUFDESCR)) {
		FF_FREE(pIoman->pBuffers);
	}

	// Ensure pCacheMem pointer was allocated.
	if((pIoman->MemAllocation & FF_IOMAN_ALLOC_BUFFERS)) {
		FF_FREE(pIoman->pCacheMem);
	}

	// Destroy any Semaphore that was created.
	if(pIoman->pSemaphore) {
		FF_DestroySemaphore(pIoman->pSemaphore);
	}
#ifdef FF_BLKDEV_USES_SEM
	if(pIoman->pBlkDevSemaphore) {
		FF_DestroySemaphore(pIoman->pBlkDevSemaphore);
	}
#endif

	// Destroy HashCache
#ifdef FF_HASH_CACHE
	for(i = 0; i < FF_HASH_CACHE_DEPTH; i++) {
		FF_DestroyHashTable(pIoman->HashCache[i].pHashTable);
	}
#endif

	// Finally free the FF_IOMAN object.
	FF_FREE(pIoman);

	return FF_ERR_NONE;
}
Example #2
0
void fnClose(HANDLE hDevice) {
	struct _DEV_INFO *ptDevInfo = (struct _DEV_INFO *) hDevice;

	if(hDevice) {
		FF_DestroySemaphore(ptDevInfo->AccessSem);
		CloseHandle(ptDevInfo->hDev);
		free(ptDevInfo);
	}
}
Example #3
0
void fnClose(BLK_DEV_LINUX pDevice) {
	fclose(pDevice->pDevice);
	FF_DestroySemaphore(pDevice->AccessSem);
	free(pDevice);
}