/* Remove all links from within a hash table. */ void CleanHash(_RTP_CONTEXT *the_context, hash_table *the_hash){ int i; for (i=0; i<HASHSIZE;i++){ CleanList(the_context, the_hash->hashval + i); } return; }
void CLiteObjectMgr::CleanObjectLists() { if (!m_bObjectListsDirty) return; // Clean the active objects if (m_aActiveObjects.size() != m_nNumActiveObjects) CleanList(m_aActiveObjects); ASSERT(m_aActiveObjects.size() == m_nNumActiveObjects); // Clean the inactive objects if (m_aInactiveObjects.size() != m_nNumInactiveObjects) CleanList(m_aInactiveObjects); ASSERT(m_aInactiveObjects.size() == m_nNumInactiveObjects); // You are clean m_bObjectListsDirty = false; // But the serialization IDs are now dirty SetDirty(eDirty_SerializeIDs); }
/** * Draw notification window */ void ToasterBox::Play() { //create new window ToasterBoxWindow* tb = new ToasterBoxWindow(parent, this); //If it is GamePromotion make window wider and show it a bit longer if (notificationType == UiEvents::EventType::GamePromoted) { const int widthCorrection = 100; const int pauseCorrection = 1000; //Add one second above standard pause tb->SetPopupSize(popupSize.GetWidth() + widthCorrection, popupSize.GetHeight()); tb->SetPopupPosition(popupPosition.x - widthCorrection, popupPosition.y); tb->SetPopupPauseTime(pauseTime + pauseCorrection); tb->SetPopupHeaderText("GAME PROMOTED!"); } else { tb->SetPopupSize(popupSize.GetWidth(), popupSize.GetHeight()); tb->SetPopupPosition(popupPosition.x, popupPosition.y); tb->SetPopupPauseTime(pauseTime); } tb->SetPopupScrollSpeed(sleepTime); tb->SetPopupTextColor(colFg.Red(), colFg.Green(), colFg.Blue()); tb->SetPopupBackgroundColor(colBg.Red(), colBg.Green(), colBg.Blue()); if (m_bitmap.IsOk()) { tb->SetPopupBitmap(m_bitmap); } else if (!bitmapFile.IsEmpty()) { tb->SetPopupBitmap(bitmapFile); } else { //No image for ToasterBox??? // wxASSERT(false); } tb->SetPopupText(popupText, true); //clean up the list CleanList(); //check to see if there is already a window displayed //by looking at the linked list if (!winList->IsEmpty()) { //there ARE other windows displayed already //reclac where it should display MoveAbove(tb); } //shift new window on to the list winList->Append(tb); //play new window if (!tb->Play()) { //if we didn't show the window properly, remove it from the list winList->DeleteNode(winList->Item(winList->GetCount() - 1)); //delete the object too. delete tb; return; } }
void ToasterBox::Notify() { //if the list is empty, skip this if (winList->IsEmpty()) return; wxLogDebug(_T("%s"), _T("clean&shrink")); //clean the window list CleanList(); //figure out how many blanks we have ToasterBoxWindowListNode node = winList->GetFirst(); if (!node) return; //( (our base position)-(position of this node) ) / (default height of the windows)+1 //long blanks = ((popupPosition.y - // node->GetData()->GetPosition().y) / popupSize.GetHeight()) +1; //move windows to fill in blank space for (int i = node->GetData()->GetPosition().y; i < popupPosition.y; i += 4) { if (i > popupPosition.y) i = popupPosition.y; //loop through all the windows for (unsigned int j = 0; j < winList->GetCount(); j++) { long ourNewHeight = i - (j * popupSize.GetHeight() - 8); ToasterBoxWindowListNode tmpNode = winList->Item(j); ToasterBoxWindow* tmpTb = tmpNode->GetData(); //reset where the object THINKS its supposed to be tmpTb->SetPopupPosition(popupPosition.x, ourNewHeight); //actually move it tmpTb->SetSize(popupPosition.x, ourNewHeight, tmpTb->GetSize().GetWidth(), tmpTb->GetSize().GetHeight()); //tmpNode = 0; tmpTb = 0; } wxMilliSleep(sleepTime); //DrawText(); //Update(); } StartAll(); //node = 0; }
void ToasterBox::Play() { //create new window ToasterBoxWindow* tb = new ToasterBoxWindow(parent, this); tb->SetPopupSize(popupSize.GetWidth(), popupSize.GetHeight()); tb->SetPopupPosition(popupPosition.x, popupPosition.y); tb->SetPopupPauseTime(pauseTime); tb->SetPopupScrollSpeed(sleepTime); tb->SetPopupTextColor(colFg.Red(), colFg.Green(), colFg.Blue()); tb->SetPopupBackgroundColor(colBg.Red(), colBg.Green(), colBg.Blue()); if (m_bitmap.IsOk()) tb->SetPopupBitmap(m_bitmap); if (!bitmapFile.IsEmpty()) tb->SetPopupBitmap(bitmapFile); tb->SetPopupText(popupText, true); //clean up the list CleanList(); //check to see if there is already a window displayed //by looking at the linked list if (!winList->IsEmpty()) { //there ARE other windows displayed already //reclac where it should display MoveAbove(tb); } //shift new window on to the list winList->Append(tb); //play new window if (!tb->Play()) { //if we didn't show the window properly, remove it from the list winList->DeleteNode(winList->Item(winList->GetCount() - 1)); //delete the object too. tb = 0; return; } }
void initLog() { uart_print("Initializing Write Log Space...\r\n"); uart_print("Initializing clean list..."); //testCleanList(); cleanListInit(&cleanListDataWrite, CleanList(0), LOG_BLK_PER_BANK); uart_print("done\r\n"); //int off = __builtin_offsetof(LogCtrlBlock, increaseLpn); for(int bank=0; bank<NUM_BANKS; bank++) { adaptiveStepDown[bank] = initStepDown; adaptiveStepUp[bank] = initStepUp; nStepUps[bank] = 0; nStepDowns[bank] = 0; for(int lbn=0; lbn<LOG_BLK_PER_BANK; lbn++) { cleanListPush(&cleanListDataWrite, bank, lbn); } UINT32 lbn = cleanListPop(&cleanListDataWrite, bank); hotLogCtrl[bank] = (LogCtrlBlock) { .logLpn = lbn * PAGES_PER_BLK, .lpnsListAddr = LPNS_BUF_BASE_1(bank), .logBufferAddr = HOT_LOG_BUF(bank), .chunkPtr = 0, .increaseLpn=increaseLpnHotBlkFirstUsage, .updateChunkPtr=updateChunkPtr, .nextLowPageOffset=INVALID, .allChunksInLogAreValid = TRUE, .useRecycledPage=FALSE, .precacheDone=TRUE, }; for(int chunk=0; chunk<CHUNKS_PER_PAGE; ++chunk) { hotLogCtrl[bank].dataLpn[chunk] = INVALID; hotLogCtrl[bank].chunkIdx[chunk] = INVALID; } lbn = cleanListPop(&cleanListDataWrite, bank); coldLogCtrl[bank] = (LogCtrlBlock) { .logLpn = lbn * PAGES_PER_BLK, .lpnsListAddr = LPNS_BUF_BASE_2(bank), .logBufferAddr = COLD_LOG_BUF(bank), .chunkPtr = 0, .increaseLpn=increaseLpnColdBlk, .updateChunkPtr=updateChunkPtr, .nextLowPageOffset=INVALID, .allChunksInLogAreValid = TRUE, .useRecycledPage=FALSE, .precacheDone=TRUE, }; for(int chunk=0; chunk<CHUNKS_PER_PAGE; ++chunk) { coldLogCtrl[bank].dataLpn[chunk] = INVALID; coldLogCtrl[bank].chunkIdx[chunk] = INVALID; } nValidChunksFromHeap[bank] = INVALID; } } static void findNewLpnForColdLog(const UINT32 bank, LogCtrlBlock * ctrlBlock) { uart_print("findNewLpnForColdLog bank "); uart_print_int(bank); if (cleanListSize(&cleanListDataWrite, bank) > 2) { uart_print(" use clean blk\r\n"); uart_print("cleanList size = "); uart_print_int(cleanListSize(&cleanListDataWrite, bank)); uart_print("\r\n"); UINT32 lbn = cleanListPop(&cleanListDataWrite, bank); ctrlBlock[bank].logLpn = lbn * PAGES_PER_BLK; ctrlBlock[bank].increaseLpn = increaseLpnColdBlk; } else { if (reuseCondition(bank)) { #if PrintStats uart_print_level_1("REUSECOLD\r\n"); #endif uart_print(" second usage\r\n"); UINT32 lbn = getVictim(&heapDataFirstUsage, bank); UINT32 nValidChunks = getVictimValidPagesNumber(&heapDataFirstUsage, bank); resetValidChunksAndRemove(&heapDataFirstUsage, bank, lbn, CHUNKS_PER_LOG_BLK_FIRST_USAGE); resetValidChunksAndRemove(&heapDataSecondUsage, bank, lbn, CHUNKS_PER_LOG_BLK_SECOND_USAGE); resetValidChunksAndRemove(&heapDataCold, bank, lbn, nValidChunks); ctrlBlock[bank].logLpn = (lbn * PAGES_PER_BLK) + 2; ctrlBlock[bank].increaseLpn = increaseLpnColdBlkReused; nand_page_ptread(bank, get_log_vbn(bank, lbn), 125, 0, (CHUNK_ADDR_BYTES * CHUNKS_PER_LOG_BLK + BYTES_PER_SECTOR - 1) / BYTES_PER_SECTOR, ctrlBlock[bank].lpnsListAddr, RETURN_WHEN_DONE); // Read the lpns list from the max low page (125) where it was previously written by incrementLpnHotBlkFirstUsage } else { uart_print(" get new block\r\n"); UINT32 lbn = cleanListPop(&cleanListDataWrite, bank); ctrlBlock[bank].logLpn = lbn * PAGES_PER_BLK; ctrlBlock[bank].increaseLpn = increaseLpnColdBlk; while(cleanListSize(&cleanListDataWrite, bank) < 2) { #if PrintStats uart_print_level_1("GCCOLD\r\n"); #endif garbageCollectLog(bank); } } } } void increaseLpnColdBlkReused (UINT32 const bank, LogCtrlBlock * ctrlBlock) { uart_print("increaseLpnColdBlkReused bank "); uart_print_int(bank); uart_print("\r\n"); UINT32 lpn = ctrlBlock[bank].logLpn; UINT32 pageOffset = LogPageToOffset(lpn); if (pageOffset == UsedPagesPerLogBlk-1) { UINT32 lbn = get_log_lbn(lpn); nand_page_ptprogram(bank, get_log_vbn(bank, lbn), PAGES_PER_BLK - 1, 0, (CHUNK_ADDR_BYTES * CHUNKS_PER_LOG_BLK + BYTES_PER_SECTOR - 1) / BYTES_PER_SECTOR, ctrlBlock[bank].lpnsListAddr, RETURN_WHEN_DONE); mem_set_dram(ctrlBlock[bank].lpnsListAddr, INVALID, (CHUNKS_PER_BLK * CHUNK_ADDR_BYTES)); insertBlkInHeap(&heapDataCold, bank, lbn); findNewLpnForColdLog(bank, ctrlBlock); } else { ctrlBlock[bank].logLpn = lpn+2; } uart_print("increaseLpnColdBlkReused (bank="); uart_print_int(bank); uart_print(") new lpn "); uart_print_int(ctrlBlock[bank].logLpn); uart_print("\r\n"); }
int main (int argc, const char * argv[]) { List* pList = NULL; char* pTmp; char* pMem_0; char* pMem_1; List* plSave = NULL; Chaine* pChaine; int i; // insert code here... printf("Hello, World!\n"); for (i = 20; i > 0; i--) { pTmp = (char*) malloc(16); memset(pTmp, 0, 16); if (i%2 == 0) sprintf(pTmp, "Ying-%d", i); else sprintf(pTmp, "Yand-%d", i); if (i == 1) pMem_0 = pTmp; if (i == 8) pMem_1 = pTmp; AddMemberOnTop(&pList, pTmp); } for (i = 0; i < pList->Count; i++) { printf("Position %d : %s\n", i, (char*)ReturnMemberAtIndex(pList, i)); } printf("+++++++++++++++\n"); SortList(&pList); for (i = 0; i < pList->Count; i++) { printf("Position %d : %s\n", i, (char*)ReturnMemberAtIndex(pList, i)); } printf("Search : %s\n", (char*)SearchInSortedList(pList, "Yand-5")); printf("+++++++++++++++\n"); SimpleRemoveMember(&pList, pMem_0); free(pMem_0); printf("++++++++++\n"); SimpleRemoveMember(&pList, pMem_1); free(pMem_1); for (i = 0; i < pList->Count; i++) { printf("Position 0 : %s\n", i, (char*)ReturnMemberAtIndex(pList, i)); } printf("+++++++++++++++\n"); CleanList(pList); return 0; }
/* Wipes all members off of the membership list */ void CleanMembershipList(_RTP_CONTEXT *the_context, membership_list *l){ CleanList(the_context, &l->actual_list); l->confirmed_members = 0; l->oldest_not_yet_soft = NULL; }