Mercurial > mm7
changeset 705:e39702f35283
memory allocation partly reworked
author | zipi |
---|---|
date | Mon, 18 Mar 2013 21:50:20 +0000 |
parents | ef4d646d738d |
children | d6236f6a9882 05f7a11f4f20 |
files | Allocator.cpp GUIButton.cpp Items.cpp LOD.cpp mm7_1.cpp |
diffstat | 5 files changed, 25 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/Allocator.cpp Tue Mar 19 01:36:47 2013 +0400 +++ b/Allocator.cpp Mon Mar 18 21:50:20 2013 +0000 @@ -21,6 +21,9 @@ //----- (00426755) -------------------------------------------------------- void *Allocator::AllocNamedChunk(const void *pPrevPtrValue, unsigned int uSize, const char *pName) { + + return malloc(uSize); +/* //Allocator *v4; // esi@1 unsigned int v5; // eax@7 void *result; // eax@8 @@ -83,7 +86,7 @@ uNextFreeOffsetInBigBuffer += aligned_size; } return pMemoryBuffers[uNumBuffersUsed]; - + */ /* //v4 = this; if ( pPrevPtrValue && !aborting_app ) @@ -181,7 +184,9 @@ //----- (00426474) -------------------------------------------------------- void Allocator::FreeChunk(void *ptr) { - Allocator *v2; // esi@1 + free(ptr); + return; +/* Allocator *v2; // esi@1 unsigned int v3; // eax@5 signed int i; // edi@5 unsigned int v5; // eax@13 @@ -230,7 +235,7 @@ } } } - + */ /* v2 = this; if ( ptr )
--- a/GUIButton.cpp Tue Mar 19 01:36:47 2013 +0400 +++ b/GUIButton.cpp Mon Mar 18 21:50:20 2013 +0000 @@ -153,7 +153,6 @@ } } --ptr->pParent->uNumControls; - pAllocator->FreeChunk(ptr); } }
--- a/Items.cpp Tue Mar 19 01:36:47 2013 +0400 +++ b/Items.cpp Mon Mar 18 21:50:20 2013 +0000 @@ -916,11 +916,6 @@ break; } - if ( pRndItemsTXT_Raw ) - { - pAllocator->FreeChunk(pRndItemsTXT_Raw); - pRndItemsTXT_Raw = NULL; - } //ChanceByTreasureLvl Summ - anti cheating? memset(&uChanceByTreasureLvlSumm, 0, 24); for(i=0;i<6;++i) @@ -1052,6 +1047,12 @@ } while ((decode_step<8)&&!break_loop); } + if ( pRndItemsTXT_Raw ) + { + pAllocator->FreeChunk(pRndItemsTXT_Raw); + pRndItemsTXT_Raw = NULL; + } + pSkillDescTXT_Raw = NULL; pSkillDescTXT_Raw = (char *)pEvents_LOD->LoadRaw("skilldes.txt", 0); strtok(pSkillDescTXT_Raw, "\r");
--- a/LOD.cpp Tue Mar 19 01:36:47 2013 +0400 +++ b/LOD.cpp Mon Mar 18 21:50:20 2013 +0000 @@ -2305,11 +2305,11 @@ if ( DstBuf.uDecompressedSize ) { if ( a3 ) - v6 = malloc(DstBuf.uDecompressedSize); + v6 = malloc(DstBuf.uDecompressedSize+1); else - v6 = pAllocator->AllocNamedChunk(0, DstBuf.uDecompressedSize, DstBuf.pName); + v6 = pAllocator->AllocNamedChunk(0, DstBuf.uDecompressedSize+1, DstBuf.pName); v7 = v6; - v8 = pAllocator->AllocNamedChunk(0, DstBuf.uTextureSize, DstBuf.pName); + v8 = pAllocator->AllocNamedChunk(0, DstBuf.uTextureSize+1, DstBuf.pName); fread(v8, 1u, Argsa, File); zlib::MemUnzip(v7, &DstBuf.uDecompressedSize, v8, DstBuf.uTextureSize); DstBuf.uTextureSize = DstBuf.uDecompressedSize; @@ -2318,9 +2318,9 @@ else { if ( a3 ) - v9 = malloc(DstBuf.uTextureSize); + v9 = malloc(DstBuf.uTextureSize+1); else - v9 = pAllocator->AllocNamedChunk(0, DstBuf.uTextureSize, DstBuf.pName); + v9 = pAllocator->AllocNamedChunk(0, DstBuf.uTextureSize+1, DstBuf.pName); v7 = v9; fread(v9, 1u, Argsa, v5); }
--- a/mm7_1.cpp Tue Mar 19 01:36:47 2013 +0400 +++ b/mm7_1.cpp Mon Mar 18 21:50:20 2013 +0000 @@ -84,10 +84,14 @@ if ( dword_507CC0 ) { dword_507CC0 = 0; - for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext ) + for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = j ) { - if ( BYTE1(i->field_1C) & 0x80 ) + j=i->pNext; + if ( BYTE1(i->field_1C) & 0x80 ) + { i->Release(); + pAllocator->FreeChunk(i); + } } for ( j = pGUIWindow_CurrentMenu->pControlsHead; j; j = j->pNext ) {