bool CSurface3DElement::Initialise(double MinX, double MaxX, long NDivsX, double MinY, double MaxY, long NDivsY) { m_bInitDone=true; m_nDivsX=NDivsX; m_dMinimumX=MinX; m_dMaximumX=MaxX; m_dDivWidthX=1; m_nDivsY=NDivsY; m_dMinimumY=MinY; m_dMaximumY=MaxY; m_dDivWidthY=1; m_dDivWidthX=(m_dMaximumX-m_dMinimumX)/NDivsX; m_dDivWidthY=(m_dMaximumY-m_dMinimumY)/NDivsY; m_bFitDone=false; m_bFitOK=false; m_bLOK=false; m_bROK=false; m_bTOK=false; m_bBOK=false; #if dbgSurfaces if (dbgInitialise()) dbgpln("I:%18.9f > %18.9f | %18.9f > %18.9f %s[Lvl:%2i] [Cnt:%6i Calls:%8i]", MinX,MaxX,MinY,MaxY, (LPCTSTR)m_r3D.m_sName, m_iLevel, m_r3D.m_nElementCnt, m_r3D.m_nCalls); #endif RemoveElements(); return true; };
BOOL CMemory::Remove(CArrayVoidPtr* pav) { int i; void* pv; SMemoryAllocation* psAlloc; CFreeList* pcList; SFNode* psNode; int iNumElements; int iChunkSize; int iRemoved; pav->QuickSort(); iNumElements = pav->NumElements(); i = 0; while (i < iNumElements) { pv = pav->GetPtr(i); psAlloc = MEMORY_GET_ALLOCATION(pv); if (psAlloc->uiSize <= (muiFreeListSizeLimit - sizeof(SMemoryAllocation))) { psNode = psAlloc->psFreeListNode; pcList = (CFreeList*)psAlloc->psFreeListNode->pcList; iChunkSize = pcList->GetChunkSize(); iRemoved = RemoveNode(pav, i, psAlloc, iChunkSize, psNode, pcList); if (iRemoved != 0) { i += iRemoved; } else { iRemoved = RemoveElements(pav, i, psNode, pcList); if (iRemoved != 0) { i += iRemoved; } else { gcLogger.Error2(__METHOD__, " Could not deallocate memory.", NULL); return FALSE; } } } else { DeallocateInLargeList(psAlloc); } } return TRUE; }
bool VValueBag::ReplaceElement( const StKey& inElementName, VValueBag *inBag) { xbox_assert( inElementName.GetKeyLength() != 0); bool ok = false; if (inBag == NULL) { RemoveElements( inElementName); } else { VBagArray *bags = GetElements( inElementName); if (bags) { // nothing to do if we already has only one element and if that's the one we are given if ( (bags->GetCount() != 1) || (bags->GetNth( 1) != inBag) ) { // the given bag may come from bags inBag->Retain(); bags->Destroy(); ok = bags->AddTail( inBag); inBag->Release(); } } else { bags = new VBagArray; if (bags != NULL) { ok = bags->AddTail( inBag); if (fElements == NULL) fElements = new VPackedVBagArrayDictionary; if (fElements != NULL) fElements->Append( inElementName, bags); bags->Release(); } } } return ok; }
CSurface3D::CSurface3D(LPCTSTR Name, double MinX, double MaxX, long NDivsX, TSurfaceXfFn fnXI, TSurfaceXfFn fnXO, double MinY, double MaxY, long NDivsY, TSurfaceXfFn fnYI, TSurfaceXfFn fnYO, TSurface3DFn Fn, CSurface3DBoundary *pBoundary) : m_E(*this, NULL, -1, 0) { m_sName=Name; m_nCalls=0; m_nElementPtrCnt=0; m_nMRULen=0; m_nMRULenMax=ALLOCCNTMAX; m_nElementCnt=0; m_nElementAllocs=0; m_pMRUHead=NULL; m_pMRUTail=NULL; m_E.Initialise(MinX, MaxX, NDivsX, MinY, MaxY, NDivsY); m_fnZ=Fn; RemoveElements(); m_dwLastTicks=GetTickCount(); };
CSurface3D::~CSurface3D() { RemoveElements(); };
CSurface3DElement::~CSurface3DElement() { m_nGlblElementCnt--; m_r3D.m_nElementCnt--; RemoveElements(); };