Beispiel #1
0
SO_PUBLIC struct Block *
Block_Clone (const struct Block *p_pSource)
{
    struct Block *l_pDestination;

	ASSERT (p_pSource != NULL);

    if ((l_pDestination = calloc(1, sizeof (struct Block))) == NULL)
    {
        rzb_log(LOG_ERR, "%s: Failed to allocate new block", __func__);
        Block_Destroy (l_pDestination);
        return NULL;
    }
    if ((l_pDestination->pId = BlockId_Clone (p_pSource->pId)) == NULL)
    {
        rzb_log (LOG_ERR, "%s: failed to clone block ID", __func__);
        Block_Destroy (l_pDestination);
        return NULL;
    }

    if (p_pSource->pParentId == NULL)
        l_pDestination->pParentId = NULL;
    else
    {
        if ((l_pDestination->pParentId = BlockId_Clone (p_pSource->pParentId)) == NULL)
        {
            rzb_log (LOG_ERR, "%s: failed due to lack of memory", __func__);
            Block_Destroy (l_pDestination);
            return NULL;
        }
    }

    l_pDestination->pMetaDataList = List_Clone(p_pSource->pMetaDataList);
    if (l_pDestination->pMetaDataList == NULL )
    {
        rzb_log (LOG_ERR,
                 "%s: failed due to failure of List_Clone", __func__);
        Block_Destroy (l_pDestination);
        return NULL;
    }

    return l_pDestination;
}
Beispiel #2
0
void inspectFile (char * fileName, uuid_t uuid) {
	void * threadData = NULL;
	if (threadInit != NULL) {
		if (!threadInit(&threadData)) {
			rzb_log(LOG_ERR, "Couldn't run nugget inspection threadInit.");
			exit(-1);
		} else {
			rzb_log(LOG_DEBUG, "Thread init for nugget complete.");
		}
	}
	sleep(sleepTime);
	struct EventId * eventId;
	eventId = calloc(1,sizeof(struct EventId));
	struct Block * block = Block_Create ();
	struct List * list	= NTLVList_Create();
	struct stat st;
	stat(fileName, &st);
	//BlockPool_Init();
	block->pId->iLength = st.st_size;
	if (!Transfer_Prepare_File(block, fileName, false)) {
		rzb_log(LOG_ERR, "Trouble preparing file transfer - '%s'", fileName);
		Block_Destroy(block);
		free(eventId);
		List_Destroy(list);
		return;
	}
	Hash_Update(block->pId->pHash, block->data.pointer, block->pId->iLength);
	Hash_Finalize(block->pId->pHash);
	uuid_copy(block->pId->uuidDataType,uuid);
	struct ContextList * current = NULL;
	while (contextList != NULL) {
		current = contextList;
		uint8_t ret = function (block, eventId, list, threadData);
		if ( ret >= 0 ) {
			rzb_log(LOG_NOTICE, "Returned with: %u", ret);
		}
		if (current == contextList)
			break;
	}
	List_Destroy(list);
	/*Don't need to free/destroy as it's done with the judgment.
	 * Was needed previously because of cloning - cloning removed*/
	//Block_Destroy(block);
	//free(eventId);
	if (threadCleanup != NULL) {
		threadCleanup(threadData);
	}
}
Beispiel #3
0
int TetrisManager_ProcessReachedCase(TetrisManager* tetrisManager){
	// ºí·ÏÀÌ µµÂø½Ã ´ÙÀ½ ºí·Ï À§Ä¡ ´Ù½Ã Ãâ·Â
	// use temp size (magic number)
	int x = 47;
	int y = 15;

	// if this variable equals to 
	static int makeObstacleOneLineCount = 0;

	_TetrisManager_PrintBlock(tetrisManager, SHADOW_BLOCK, EMPTY);
	_TetrisManager_ChangeBoardByStatus(tetrisManager, SHADOW_BLOCK, EMPTY);
	_TetrisManager_PrintBlock(tetrisManager, MOVING_BLOCK, EMPTY);
	_TetrisManager_ChangeBoardByStatus(tetrisManager, MOVING_BLOCK, FIXED_BLOCK);
	_TetrisManager_PrintBlock(tetrisManager, FIXED_BLOCK, FIXED_BLOCK);
	tetrisManager->block = Block_Make(False, tetrisManager->block);
	_TetrisManager_PrintBlock(tetrisManager, MOVING_BLOCK, MOVING_BLOCK);
	_TetrisManager_MakeShadow(tetrisManager);
	if (makeObstacleOneLineCount == MAX_MAKE_OBSTACLE_ONE_LINE_COUNT){
		if (tetrisManager->speedLevel == MAX_SPEED_LEVEL){
			_TetrisManager_MakeObstacleOneLine(tetrisManager);
		}
		makeObstacleOneLineCount = 0;
	} else{
		makeObstacleOneLineCount++;
	}
	
	/*Block_PrintNext(tetrisManager->block, 0, x, y);
	x += 20;
	Block_PrintNext(tetrisManager->block, 1, x, y);*/

	tetrisManager->isHoldAvailable = True;
	if (TetrisManager_IsReachedToBottom(tetrisManager, MOVING_BLOCK)){
		Block_Destroy(tetrisManager->block);
		return END;
	}
	else{
		return PLAYING;
	}
}