diff options
| author | oy <Tom_Adams@web.de> | 2012-07-08 13:13:21 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2013-02-24 17:41:15 +0100 |
| commit | ff75c3ba2d1df54ec5f53da2ce502cfd33c182e0 (patch) | |
| tree | b90a8c4fca57f7b2f2fece6c804b2eb91938ebd5 /src | |
| parent | 865d0f736588337fc7b8cc925eb84bc2dd2ae7f0 (diff) | |
| download | zcatch-ff75c3ba2d1df54ec5f53da2ce502cfd33c182e0.tar.gz zcatch-ff75c3ba2d1df54ec5f53da2ce502cfd33c182e0.zip | |
fixed some memory leaks in the map editor
Diffstat (limited to 'src')
| -rw-r--r-- | src/game/editor/editor.cpp | 11 | ||||
| -rw-r--r-- | src/game/editor/io.cpp | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index fa1024e0..2c67c021 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -37,6 +37,11 @@ enum CEditorImage::~CEditorImage() { m_pEditor->Graphics()->UnloadTexture(m_TexID); + if(m_pData) + { + mem_free(m_pData); + m_pData = 0; + } } CLayerGroup::CLayerGroup() @@ -2423,6 +2428,11 @@ void CEditor::ReplaceImage(const char *pFileName, int StorageType, void *pUser) CEditorImage *pImg = pEditor->m_Map.m_lImages[pEditor->m_SelectedImage]; int External = pImg->m_External; pEditor->Graphics()->UnloadTexture(pImg->m_TexID); + if(pImg->m_pData) + { + mem_free(pImg->m_pData); + pImg->m_pData = 0; + } *pImg = ImgInfo; pImg->m_External = External; pEditor->ExtractName(pFileName, pImg->m_aName, sizeof(pImg->m_aName)); @@ -2456,6 +2466,7 @@ void CEditor::AddImage(const char *pFileName, int StorageType, void *pUser) CEditorImage *pImg = new CEditorImage(pEditor); *pImg = ImgInfo; pImg->m_TexID = pEditor->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, CImageInfo::FORMAT_AUTO, 0); + ImgInfo.m_pData = 0; pImg->m_External = 1; // external by default str_copy(pImg->m_aName, aBuf, sizeof(pImg->m_aName)); pImg->m_AutoMapper.Load(pImg->m_aName); diff --git a/src/game/editor/io.cpp b/src/game/editor/io.cpp index 463147e1..529638cf 100644 --- a/src/game/editor/io.cpp +++ b/src/game/editor/io.cpp @@ -391,6 +391,7 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName) } df.AddItem(MAPITEMTYPE_ENVPOINTS, 0, TotalSize, pPoints); + mem_free(pPoints); // finish the data file df.Finish(); @@ -479,6 +480,7 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag { *pImg = ImgInfo; pImg->m_TexID = m_pEditor->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, CImageInfo::FORMAT_AUTO, 0); + ImgInfo.m_pData = 0; pImg->m_External = 1; } } |