From cd4273cd16f0cb84e37330de981a20ee1cdbd7ce Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Wed, 10 Aug 2005 01:27:33 +0000 Subject: [PATCH] Oops, I broke it. Fixed by reinserting memory leak. This was SVN commit r2596. --- source/graphics/TextureManager.cpp | 36 ++++++++++-------------------- source/lib/sysdep/win/wpthread.cpp | 3 ++- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/source/graphics/TextureManager.cpp b/source/graphics/TextureManager.cpp index e2a3b93855..9b686fb1b6 100755 --- a/source/graphics/TextureManager.cpp +++ b/source/graphics/TextureManager.cpp @@ -109,22 +109,15 @@ void CTextureManager::LoadTextures(CTerrainProperties *props, CStr path, const c // Has XML file -> attempt to load properties if (vfs_exists(xmlname.c_str())) myprops=GetPropertiesFromFile(props, xmlname); - - CTerrainProperties *usedProps = NULL; - if (myprops) - { - LOG(NORMAL, LOG_CATEGORY, "CTextureManager: Successfully loaded override xml %s for texture %s\n", xmlname.c_str(), dent.name); - usedProps = myprops; - } - else - { - // Error or non-existant xml file -> use parent props - usedProps = props; - } - AddTexture(usedProps, path+dent.name); - - delete myprops; + if (myprops) + LOG(NORMAL, LOG_CATEGORY, "CTextureManager: Successfully loaded override xml %s for texture %s\n", xmlname.c_str(), dent.name); + + // Error or non-existant xml file -> use parent props + if (!myprops) + myprops = props; + + AddTexture(myprops, path+dent.name); } vfs_dir_close(dir); @@ -136,17 +129,14 @@ void CTextureManager::RecurseDirectory(CTerrainProperties *parentProps, CStr pat LOG(NORMAL, LOG_CATEGORY, "CTextureManager::RecurseDirectory(%s)", path.c_str()); // Load terrains.xml first, if it exists - CTerrainProperties *loadedProps=NULL; + CTerrainProperties *props=NULL; CStr xmlpath=path+"terrains.xml"; if (vfs_exists(xmlpath.c_str())) - loadedProps=GetPropertiesFromFile(parentProps, xmlpath); + props=GetPropertiesFromFile(parentProps, xmlpath); - CTerrainProperties *props=NULL; - if (loadedProps) - props = loadedProps; - else + // No terrains.xml, or read failures -> use parent props (i.e. + if (!props) { - // No terrains.xml, or read failures -> use parent props LOG(NORMAL, LOG_CATEGORY, "CTextureManager::RecurseDirectory(%s): no terrains.xml (or errors while loading) - using parent properties", path.c_str()); props = parentProps; @@ -171,8 +161,6 @@ void CTextureManager::RecurseDirectory(CTerrainProperties *parentProps, CStr pat { LoadTextures(props, path, SupportedTextureFormats[i]); } - - delete loadedProps; } diff --git a/source/lib/sysdep/win/wpthread.cpp b/source/lib/sysdep/win/wpthread.cpp index b13db26b59..0ba43fc8af 100644 --- a/source/lib/sysdep/win/wpthread.cpp +++ b/source/lib/sysdep/win/wpthread.cpp @@ -129,7 +129,8 @@ int pthread_key_create(pthread_key_t* key, void (*dtor)(void*)) *key = (pthread_key_t)idx; // acquire a free dtor slot - for(uint i = 0; i < MAX_DTORS; i++) + uint i; + for(i = 0; i < MAX_DTORS; i++) { if(CAS(&dtors[i].dtor, 0, dtor)) goto have_slot;