void FixedAlloc::Destroy() { // Free all of the blocks while (m_firstBlock) { #ifdef MMGC_MEMORY_PROFILER if(m_firstBlock->numAlloc > 0 && m_heap->GetStatus() != kMemAbort) { union { char* mem_c; uint32_t* mem; }; mem_c = m_firstBlock->items; unsigned int itemNum = 0; while(itemNum++ < m_itemsPerBlock) { if(IsInUse(m_firstBlock, mem)) { GCLog("Leaked %d byte item. Addr: 0x%p\n", GetItemSize(), GetUserPointer(mem)); PrintAllocStackTrace(GetUserPointer(mem)); } mem_c += m_itemSize; } } #ifdef MMGC_MEMORY_INFO //check for writes on deleted memory VerifyFreeBlockIntegrity(m_firstBlock->firstFree, m_firstBlock->size); #endif #endif FreeChunk(m_firstBlock); } m_firstBlock = NULL; }
FixedAlloc::~FixedAlloc() { // Free all of the blocks while (m_firstBlock) { #ifdef MEMORY_INFO if(m_firstBlock->numAlloc > 0) { // go through every memory location, if the fourth 4 bytes cast as // an integer isn't 0xedededed then its allocated space and the integer is // an index into the stack trace table, the first 4 bytes will contain // the freelist pointer for free'd items (which is why the trace index is // stored in the second 4) // first 4 bytes - free list pointer // 2nd 4 bytes - alloc stack trace // 3rd 4 bytes - free stack trace // 4th 4 bytes - 0xedededed if freed correctly unsigned int *mem = (unsigned int*) m_firstBlock->items; unsigned int itemNum = 0; while(itemNum++ < m_itemsPerBlock) { unsigned int fourthInt = *(mem+3); if(fourthInt != 0xedededed) { GCDebugMsg(false, "Leaked %d byte item. Addr: 0x%x\n", GetItemSize(), mem+2); PrintStackTraceByIndex(*(mem+1)); } mem += (m_itemSize / sizeof(int)); } GCAssert(false); } // go through every item on the free list and make sure it wasn't written to // after being poisoned. void *item = m_firstBlock->firstFree; while(item) { #ifdef MMGC_64BIT for(int i=3, n=(m_firstBlock->size>>2)-3; i<n; i++) #else for(int i=3, n=(m_firstBlock->size>>2)-1; i<n; i++) #endif { unsigned int data = ((int*)item)[i]; if(data != 0xedededed) { GCDebugMsg(false, "Object 0x%x was written to after it was deleted, allocation trace:"); PrintStackTrace((int*)item+2); GCDebugMsg(false, "Deletion trace:"); PrintStackTrace((int*)item+3); GCDebugMsg(true, "Deleted item write violation!"); } } // next free item item = *((void**)item); } #endif FreeChunk(m_firstBlock); } }
void CSnapshot::DebugDump() { dbg_msg("snapshot", "data_size=%d num_items=%d", m_DataSize, m_NumItems); for(int i = 0; i < m_NumItems; i++) { CSnapshotItem *pItem = GetItem(i); int Size = GetItemSize(i); dbg_msg("snapshot", "\ttype=%d id=%d", pItem->Type(), pItem->ID()); for(int b = 0; b < Size/4; b++) dbg_msg("snapshot", "\t\t%3d %12d\t%08x", b, pItem->Data()[b], pItem->Data()[b]); } }
void wxBitmapComboBox::DrawItem(wxDC &dc, int n) const { wxSize itemSize(GetItemSize()); //((wxWindow*)GetLabelWindow())->GetClientSize().x, dy); wxPoint labelPos, bitmapPos; CalcLabelBitmapPos(n, itemSize, labelPos, bitmapPos); if (GetBitmap(n).Ok()) dc.DrawBitmap(GetBitmap(n), bitmapPos.x, bitmapPos.y, true); if (!GetLabel(n).IsEmpty()) dc.DrawText(GetLabel(n), labelPos.x, labelPos.y); }
void CCaliData::CancelIntPeakMark(int no){ int find_no=0; for (int i=0; i<GetItemSize(); i++) { if (m_CaliItems[i].szIsInterior == _T("是")) { if (find_no==no) { m_CaliItems[i].szIsInterior = _T("否"); } } } }
void CCaliData::CancelRefPeakMark(int no){ int find_no=0; for (int i=0; i<GetItemSize(); i++) { if (m_CaliItems[i].szIsReference == _T("是")) { if (find_no==no) { m_CaliItems[i].szIsReference = _T("否"); } } } }
int CSnapshot::Crc() { int Crc = 0; for(int i = 0; i < m_NumItems; i++) { CSnapshotItem *pItem = GetItem(i); int Size = GetItemSize(i); for(int b = 0; b < Size/4; b++) Crc += pItem->Data()[b]; } return Crc; }
void CCaliData::CaliTable2CaliResultTable(const CCaliData& CaliTable){ CCaliData temp; CaliTable.GenerateDuplicate(temp); const int tempSize = temp.GetItemSize(); const int caliItemsSize = GetItemSize(); int currSize = (tempSize > caliItemsSize) ? caliItemsSize : tempSize; for (int i=0; i<currSize; ++i) { temp.m_CaliItems[i].szStdContent = m_CaliItems[i].szStdContent; } temp.m_CaliItems.swap(m_CaliItems); }
void FixedAlloc::Destroy() { // Free all of the blocks while (m_firstBlock) { #ifdef MMGC_MEMORY_PROFILER if(m_firstBlock->numAlloc > 0 && m_heap->GetStatus() != kMemAbort) { union { char* mem_c; uint32_t* mem; }; mem_c = m_firstBlock->items; unsigned int itemNum = 0; while(itemNum++ < m_itemsPerBlock) { if(IsInUse(m_firstBlock, mem)) { // supress output in release build UNLESS the profiler is on #ifndef GCDEBUG if(m_heap->GetProfiler() != NULL) #endif { GCLog("Leaked %d byte item. Addr: 0x%p\n", GetItemSize(), GetUserPointer(mem)); PrintAllocStackTrace(GetUserPointer(mem)); } } mem_c += m_itemSize; } } #ifdef MMGC_MEMORY_INFO //check for writes on deleted memory VerifyFreeBlockIntegrity(m_firstBlock->firstFree, m_firstBlock->size); #endif #endif // Note, don't cache any state across this call; FreeChunk may temporarily // release locks held if the true type of this allocator is FixedAllocSafe. FreeChunk(m_firstBlock); } m_firstBlock = NULL; }
void OBSBasicPreview::GetStretchHandleData(const vec2 &pos) { OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow()); OBSScene scene = main->GetCurrentScene(); if (!scene) return; HandleFindData data(pos, main->previewScale); obs_scene_enum_items(scene, FindHandleAtPos, &data); stretchItem = std::move(data.item); stretchHandle = data.handle; if (stretchHandle != ItemHandle::None) { matrix4 boxTransform; vec3 itemUL; float itemRot; stretchItemSize = GetItemSize(stretchItem); obs_sceneitem_get_box_transform(stretchItem, &boxTransform); itemRot = obs_sceneitem_getrot(stretchItem); vec3_from_vec4(&itemUL, &boxTransform.t); /* build the item space conversion matrices */ matrix4_identity(&itemToScreen); matrix4_rotate_aa4f(&itemToScreen, &itemToScreen, 0.0f, 0.0f, 1.0f, RAD(itemRot)); matrix4_translate3f(&itemToScreen, &itemToScreen, itemUL.x, itemUL.y, 0.0f); matrix4_identity(&screenToItem); matrix4_translate3f(&screenToItem, &screenToItem, -itemUL.x, -itemUL.y, 0.0f); matrix4_rotate_aa4f(&screenToItem, &screenToItem, 0.0f, 0.0f, 1.0f, RAD(-itemRot)); } }
void CRemoteFileDialog::UpdateFileResults() { m_aFiles.RemoveAll(); if (m_sFilenames.IsEmpty()) { return; } // we just parse m_sFilenames CString sFileNames(m_sFilenames); BOOL bMustExist = FileMustExist(); // for downloads int nStartQuote = sFileNames.Find(_T('\"')); if (nStartQuote == -1) { // single file sFileNames.TrimLeft(); sFileNames.TrimRight(); int nFindMatch = FindMatch(sFileNames); if (!bMustExist || nFindMatch != -1) { CString sFilePath(sFileNames); if (!m_bRoot) { sFilePath.Format(_T("%s/%s"), m_sCurFolder, sFileNames); } m_aFiles.Add(FILERESULT(sFilePath, GetItemSize(nFindMatch))); } } else // look for pairs of quotes { while (nStartQuote != -1) { int nEndQuote = sFileNames.Find('\"', nStartQuote + 1); if (nEndQuote != -1) { CString sFileName = sFileNames.Mid(nStartQuote + 1, nEndQuote - 1 - nStartQuote); sFileName.TrimLeft(); sFileName.TrimRight(); int nFindMatch = FindMatch(sFileName); if (!bMustExist || nFindMatch != -1) { CString sFilePath(sFileName); if (!m_bRoot) { sFilePath.Format(_T("%s/%s"), m_sCurFolder, sFileName); } m_aFiles.Add(FILERESULT(sFilePath, GetItemSize(nFindMatch))); } // next pair nStartQuote = sFileNames.Find(_T('\"'), nEndQuote + 1); } else { nStartQuote = -1; // we're done } } } }
void CRemoteFileDialog::OnItemchangedFilelist(NMHDR* /*pNMHDR*/, LRESULT* pResult) { *pResult = 0; if (m_bFilling) { return; } // rebuild results at the same time int nSelCount = m_lcFiles.GetSelectedCount(); if (nSelCount == 1) { int nSel = GetFirstSelectedItem(); if (GetItemType(nSel) == RFDT_FILE || FolderSelect()) { // save result CString sFileName = m_lcFiles.GetItemText(nSel, 0); CString sFilePath(sFileName); if (!m_bRoot) { sFilePath.Format(_T("%s/%s"), m_sCurFolder, sFileName); } m_aFiles.RemoveAll(); m_aFiles.Add(FILERESULT(sFilePath, GetItemSize(nSel))); // update current filename m_sFilenames = sFileName; } } else if (nSelCount > 1) { m_sFilenames.Empty(); POSITION pos = m_lcFiles.GetFirstSelectedItemPosition(); while (pos) { int nItem = m_lcFiles.GetNextSelectedItem(pos); if (nItem != -1 && GetItemType(nItem) == RFDT_FILE) { // save result CString sFileName = m_lcFiles.GetItemText(nItem, 0); CString sFilePath(sFileName); if (!m_bRoot) { sFilePath.Format(_T("%s/%s"), m_sCurFolder, sFileName); } m_aFiles.Add(FILERESULT(sFilePath, GetItemSize(nItem))); // update current filename CString sItem; sItem.Format(_T("\"%s\" "), sFileName); m_sFilenames += sItem; } } } UpdateData(FALSE); UpdateOKButton(FALSE); }