void CXRayObjectExport::destroyEdgeTable() // // Free up all of the memory used by the edgeTable. // { //. if ( !smoothing ) return; SXREdgeInfoPtr element = NULL; SXREdgeInfoPtr tmp = NULL; for ( int v=0; v<edgeTableSize; v++ ) { element = edgeTable[v]; while ( NULL != element ) { tmp = element; element = element->next; xr_free( tmp ); } } if ( NULL != edgeTable ) { xr_free( edgeTable ); edgeTable = NULL; } if ( NULL != polySmoothingGroups ) { xr_free( polySmoothingGroups ); polySmoothingGroups = NULL; } }
bool CScriptStorage::parse_namespace(LPCSTR caNamespaceName, LPSTR b, LPSTR c) { strcpy (b,""); strcpy (c,""); LPSTR S2 = xr_strdup(caNamespaceName); LPSTR S = S2; for (int i=0;;++i) { if (!xr_strlen(S)) { script_log (ScriptStorage::eLuaMessageTypeError,"the namespace name %s is incorrect!",caNamespaceName); xr_free (S2); return (false); } LPSTR S1 = strchr(S,'.'); if (S1) *S1 = 0; if (i) strcat (b,"{"); strcat (b,S); strcat (b,"="); if (i) strcat (c,"}"); if (S1) S = ++S1; else break; } xr_free (S2); return (true); }
CContextMenu::~CContextMenu(){ for (xr_vector<MenuItem>::iterator I=Items.begin(); Items.end()!=I; ++I){ Engine.Event.Destroy(I->Event); xr_free(I->Name); xr_free(I->Param); } xr_free(Name); }
/* void fill_render_mode_list() { if(vid_quality_token != NULL) return; D3DCAPS9 caps; CHW _HW; _HW.CreateD3D (); _HW.pD3D->GetDeviceCaps (D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,&caps); _HW.DestroyD3D (); u16 ps_ver_major = u16 ( u32(u32(caps.PixelShaderVersion)&u32(0xf << 8ul))>>8 ); xr_vector<LPCSTR> _tmp; u32 i = 0; for(; i<5; ++i) { bool bBreakLoop = false; switch (i) { case 3: //"renderer_r2.5" if (ps_ver_major < 3) bBreakLoop = true; break; case 4: //"renderer_r_dx10" bBreakLoop = true; break; default: ; } if (bBreakLoop) break; _tmp.push_back (NULL); LPCSTR val = NULL; switch (i) { case 0: val ="renderer_r1"; break; case 1: val ="renderer_r2a"; break; case 2: val ="renderer_r2"; break; case 3: val ="renderer_r2.5"; break; case 4: val ="renderer_r_dx10"; break; // -) } _tmp.back() = xr_strdup(val); } u32 _cnt = _tmp.size()+1; vid_quality_token = xr_alloc<xr_token>(_cnt); vid_quality_token[_cnt-1].id = -1; vid_quality_token[_cnt-1].name = NULL; #ifdef DEBUG Msg("Available render modes[%d]:",_tmp.size()); #endif // DEBUG for(u32 i=0; i<_tmp.size();++i) { vid_quality_token[i].id = i; vid_quality_token[i].name = _tmp[i]; #ifdef DEBUG Msg ("[%s]",_tmp[i]); #endif // DEBUG } } */ void free_vid_mode_list() { for( int i=0; vid_mode_token[i].name; i++ ) { xr_free (vid_mode_token[i].name); } xr_free (vid_mode_token); vid_mode_token = NULL; }
void FProgressive::Release () { Fvisual::Release(); xr_free (nSWI.sw); if (xSWI) { xr_free (xSWI->sw); xr_delete (xSWI); } }
void CSoundRender_Cache::destroy () { disconnect (); xr_free (data); xr_free (c_storage); c_begin = NULL; c_end = NULL; _total = 0; _line = 0; _count = 0; }
CSoundStream::~CSoundStream ( ) { Stop ( ); FS.r_close (hf); xr_free (WaveSource); xr_free (WaveDest); xr_free (pwfx); xr_free (psrc); _RELEASE (pBuffer); }
CEngineAPI::~CEngineAPI() { // destroy quality token here if (vid_quality_token) { for( int i=0; vid_quality_token[i].name; i++ ) { xr_free (vid_quality_token[i].name); } xr_free (vid_quality_token); vid_quality_token = NULL; } }
void CRender::LoadSWIs(CStreamReader* base_fs) { // allocate memory for portals if (base_fs->find_chunk(fsL_SWIS)){ CStreamReader *fs = base_fs->open_chunk(fsL_SWIS); u32 item_count = fs->r_u32(); xr_vector<FSlideWindowItem>::iterator it = SWIs.begin(); xr_vector<FSlideWindowItem>::iterator it_e = SWIs.end(); for(;it!=it_e;++it) xr_free( (*it).sw ); SWIs.clear_not_free(); SWIs.resize (item_count); for (u32 c=0; c<item_count; c++){ FSlideWindowItem& swi = SWIs[c]; swi.reserved[0] = fs->r_u32(); swi.reserved[1] = fs->r_u32(); swi.reserved[2] = fs->r_u32(); swi.reserved[3] = fs->r_u32(); swi.count = fs->r_u32(); VERIFY (NULL==swi.sw); swi.sw = xr_alloc<FSlideWindow> (swi.count); fs->r (swi.sw,sizeof(FSlideWindow)*swi.count); } fs->close (); } }
void EDetailManager::ClearSlots() { ZeroMemory (&dtH,sizeof(DetailHeader)); xr_free (dtSlots); m_Selected.clear (); InvalidateCache (); }
void CKinematics::IBoneInstances_Destroy() { if (bone_instances) { xr_free(bone_instances); bone_instances = NULL; } }
void EDetail::Export(IWriter& F, LPCSTR tex_name, const Fvector2& offs, const Fvector2& scale, bool rot) { R_ASSERT (m_pRefs); CSurface* surf = *m_pRefs->FirstSurface(); R_ASSERT (surf); // write data F.w_stringZ (surf->_ShaderName()); F.w_stringZ (tex_name);//surf->_Texture()); F.w_u32 (m_Flags.get()); F.w_float (m_fMinScale); F.w_float (m_fMaxScale); F.w_u32 (number_vertices); F.w_u32 (number_indices); // remap UV EVertexIn* rm_vertices = xr_alloc<EVertexIn>(number_vertices); for (u32 k=0; k<number_vertices; k++) rm_vertices[k].remapUV(vertices[k],offs,scale,rot); F.w (rm_vertices, number_vertices*sizeof(fvfVertexIn)); F.w (indices, number_indices*sizeof(WORD)); xr_free (rm_vertices); }
static LPVOID __cdecl luabind_allocator ( luabind::memory_allocation_function_parameter const, void const * const pointer, size_t const size ) { if (!size) { LPVOID non_const_pointer = const_cast<LPVOID>(pointer); xr_free (non_const_pointer); return ( 0 ); } if (!pointer) { #ifdef DEBUG return ( Memory.mem_alloc(size, "luabind") ); #else // #ifdef DEBUG return ( Memory.mem_alloc(size) ); #endif // #ifdef DEBUG } LPVOID non_const_pointer = const_cast<LPVOID>(pointer); #ifdef DEBUG return ( Memory.mem_realloc(non_const_pointer, size, "luabind") ); #else // #ifdef DEBUG return ( Memory.mem_realloc(non_const_pointer, size) ); #endif // #ifdef DEBUG }
CLightShadows::~CLightShadows() { // Debug sh_Screen.destroy (); geom_Screen.destroy (); geom_Blur.destroy (); geom_World.destroy (); sh_BlurRT.destroy (); sh_BlurTR.destroy (); sh_World.destroy (); RT_temp.destroy (); RT.destroy (); // casters for (u32 it=0; it<casters_pool.size(); it++) xr_delete(casters_pool[it]); casters_pool.clear (); // cache for (u32 it=0; it<cache.size(); it++) xr_free (cache[it].tris); cache.clear (); }
void CSoundStream::Play ( BOOL loop, int cnt ) { VERIFY(Sound); if (isPause) { Pause(); return; } if (dwStatus & DSBSTATUS_PLAYING) return; dwDecPos = 0; isPresentData = true; //---------------- if (hAcmStream){ CHK_DX(acmStreamClose(hAcmStream,0)); } CHK_DX(acmStreamOpen(&hAcmStream,0,psrc,pwfx,0,NULL,0,0)); CHK_DX(acmStreamSize(hAcmStream,dwDestBufSize,LPDWORD(&dwSrcBufSize),ACM_STREAMSIZEF_DESTINATION)); // alloc source data buffer VERIFY(dwSrcBufSize); xr_free(WaveSource); WaveSource = (unsigned char *)xr_malloc(dwSrcBufSize); // seek to data start hf->seek (DataPos); writepos = 0; Decompress (WaveDest); writepos =stream.cbDstLengthUsed; //------- iLoopCountRested= cnt; bMustLoop = loop; bMustPlay = true; }
void CImage::Create(u32 w, u32 h) { xr_free (pData); dwWidth = w; dwHeight = h; pData = (u32*)(xr_malloc(w*h*sizeof(u32))); }
dx10ConstantBuffer::~dx10ConstantBuffer() { DEV->_DeleteConstantBuffer(this); // Flush(); _RELEASE(m_pBuffer); xr_free(m_pBufferData); }
//////////////////////////////////////////////////////////////////////////////////////// // RemoveSmallStrips() // // allStrips is the whole strip _vector_...all small strips will be deleted from this list, to avoid leaking mem // allBigStrips is an out parameter which will contain all strips above minStripLength // faceList is an out parameter which will contain all faces which were removed from the striplist // void NvStripifier::RemoveSmallStrips(NvStripInfoVec& allStrips, NvStripInfoVec& allBigStrips, NvFaceInfoVec& faceList) { faceList.clear(); allBigStrips.clear(); //make sure these are empty NvFaceInfoVec tempFaceList; for(int i = 0; i < allStrips.size(); i++) { if(allStrips[i]->m_faces.size() < minStripLength) { //strip is too small, add faces to faceList for(int j = 0; j < allStrips[i]->m_faces.size(); j++) tempFaceList.push_back(allStrips[i]->m_faces[j]); //and xr_free memory xr_delete(allStrips[i]); } else { allBigStrips.push_back(allStrips[i]); } } bool *bVisitedList = xr_alloc<bool> (tempFaceList.size()); ZeroMemory (bVisitedList, tempFaceList.size()*sizeof(bool)); VertexCache* vcache = xr_new<VertexCache> (cacheSize); int bestNumHits = -1; int numHits = 0; int bestIndex = 0; while(1) { bestNumHits = -1; //find best face to add next, given the current cache for(int i = 0; i < tempFaceList.size(); i++) { if(bVisitedList[i]) continue; numHits = CalcNumHitsFace(vcache, tempFaceList[i]); if(numHits > bestNumHits) { bestNumHits = numHits; bestIndex = i; } } if(bestNumHits == -1.0f) break; bVisitedList[bestIndex] = true; UpdateCacheFace(vcache, tempFaceList[bestIndex]); faceList.push_back(tempFaceList[bestIndex]); } xr_delete (vcache); xr_free (bVisitedList); }
CGameFont::~CGameFont() { if ( TCMap ) xr_free( TCMap ); // Shading RenderFactory->DestroyFontRender(pFontRender); }
void CKinematicsAnimated::IBoneInstances_Destroy() { inherited::IBoneInstances_Destroy(); if (blend_instances) { xr_free(blend_instances); blend_instances = NULL; } }
void CSoundStream::Load( LPCSTR name ) { if (name) { xr_free (fName); fName = xr_strdup(name); } LoadADPCM ( ); bNeedUpdate = true; }
void CResourceManager::OnDeviceDestroy(BOOL ) { if (RDEVICE.b_is_Ready) return; m_textures_description.UnLoad (); // Matrices for (map_Matrix::iterator m=m_matrices.begin(); m!=m_matrices.end(); m++) { R_ASSERT (1==m->second->dwReference); xr_delete (m->second); } m_matrices.clear (); // Constants for (map_Constant::iterator c=m_constants.begin(); c!=m_constants.end(); c++) { R_ASSERT (1==c->second->dwReference); xr_delete (c->second); } m_constants.clear (); // Release blenders for (map_BlenderIt b=m_blenders.begin(); b!=m_blenders.end(); b++) { xr_free ((char*&)b->first); IBlender::Destroy (b->second); } m_blenders.clear (); // destroy TD for (map_TDIt _t=m_td.begin(); _t!=m_td.end(); _t++) { xr_free ((char*&)_t->first); xr_free ((char*&)_t->second.T); xr_delete (_t->second.cs); } m_td.clear (); // scripting #ifndef _EDITOR LS_Unload (); #endif }
void ReplaceSpaceAndLowerCase(shared_str& s) { if (*s){ char* _s = xr_strdup(*s); char* lp = _s; while(lp[0]){if (lp[0]==' ') lp[0]='_'; lp++;} xr_strlwr (_s); s = _s; xr_free (_s); } }
void CLevel::Demo_Clear () { WriteStoredDemo(); m_bDemoSaveMode = FALSE; xr_free(m_pStoredDemoData); m_dwStoredDemoDataSize = 0; if (!g_bLeaveTDemo) { DeleteFile(m_sDemoName); }; };
void CSoundStream::Stop ( ) { int code; xr_free(WaveSource); if (hAcmStream) { code=acmStreamClose(hAcmStream,0); VERIFY2(code==0,"Can't close stream"); } hAcmStream = 0; pBuffer->Stop ( ); pBuffer->SetCurrentPosition ( 0 ); dwStatus = 0; isPause = false; }
CPatternFunction::~CPatternFunction() { xr_free (m_dwaVariableTypes); xr_free (m_dwaAtomicFeatureRange); xr_free (m_dwaPatternIndexes); for (u32 i=0; i<m_dwPatternCount; ++i) xr_free (m_tpPatterns[i].dwaVariableIndexes); xr_free (m_tpPatterns); xr_free (m_faParameters); xr_free (m_dwaVariableValues); }
void IWriter::w_compressed(void* ptr, u32 count) { BYTE* dest = 0; unsigned dest_sz = 0; _compressLZ(&dest, &dest_sz, ptr, count); // if (g_dummy_stuff) // g_dummy_stuff (dest,dest_sz,dest); if (dest && dest_sz) w(dest, dest_sz); xr_free(dest); }
void CXRayObjectExport::freeLookupTables() // // Frees up all tables and arrays allocated by this plug-in. // { if (vertexTablePtr){ for ( int i=0; i<objectCount; i++ ) { if ( vertexTablePtr[i] != NULL ) { xr_free( vertexTablePtr[i] ); } } } if (polygonTablePtr){ for ( int i=0; i<objectCount; i++ ) { if ( polygonTablePtr[i] != NULL ) { xr_free( polygonTablePtr[i] ); } } } if (objectGroupsTablePtr) { for ( int i=0; i<objectCount; i++ ) { if ( objectGroupsTablePtr[i] != NULL ) { xr_free( objectGroupsTablePtr[i] ); } } xr_free( objectGroupsTablePtr ); objectGroupsTablePtr = NULL; } if ( vertexTablePtr != NULL ) { xr_free( vertexTablePtr ); vertexTablePtr = NULL; } if ( polygonTablePtr != NULL ) { xr_free( polygonTablePtr ); polygonTablePtr = NULL; } if ( lastSets != NULL ) { xr_delete(lastSets); lastSets = NULL; } if ( lastMaterials != NULL ) { xr_delete(lastMaterials); lastMaterials = NULL; } if ( sets != NULL ) { xr_delete(sets); sets = NULL; } if ( objectNames != NULL ) { xr_delete(objectNames); objectNames = NULL; } }
static void *lua_alloc_xr (void *ud, void *ptr, size_t osize, size_t nsize) { (void)ud; (void)osize; if (nsize == 0) { xr_free (ptr); return NULL; } else #ifdef DEBUG_MEMORY_NAME return Memory.mem_realloc (ptr, nsize, "LUA"); #else // DEBUG_MEMORY_MANAGER return Memory.mem_realloc (ptr, nsize); #endif // DEBUG_MEMORY_MANAGER }
void CEditableMesh::Clear() { #ifdef _EDITOR UnloadRenderBuffers (); #endif UnloadAdjacency (); UnloadCForm (); UnloadFNormals (); UnloadVNormals (); UnloadSVertices (); VERIFY (m_FNormalsRefs==0 && m_VNormalsRefs==0 && m_AdjsRefs==0 && m_SVertRefs==0); xr_free (m_Verts); xr_free (m_Faces); for (VMapIt vm_it=m_VMaps.begin(); vm_it!=m_VMaps.end(); vm_it++) xr_delete (*vm_it); m_VMaps.clear (); m_SurfFaces.clear (); for (VMRefsIt ref_it=m_VMRefs.begin(); ref_it!=m_VMRefs.end(); ref_it++) xr_free (ref_it->pts); m_VMRefs.clear (); }