Mercurial > might-and-magic-trilogy
comparison Allocator.cpp @ 26:93bf1d5f6a6d
Game loading.
author | Nomad |
---|---|
date | Tue, 16 Oct 2012 00:05:53 +0200 |
parents | 8b8875f5b359 |
children | a84fb3752681 |
comparison
equal
deleted
inserted
replaced
25:2bbf33898c6b | 26:93bf1d5f6a6d |
---|---|
19 | 19 |
20 | 20 |
21 //----- (00426755) -------------------------------------------------------- | 21 //----- (00426755) -------------------------------------------------------- |
22 void *Allocator::AllocNamedChunk(const void *pPrevPtrValue, unsigned int uSize, const char *pName) | 22 void *Allocator::AllocNamedChunk(const void *pPrevPtrValue, unsigned int uSize, const char *pName) |
23 { | 23 { |
24 Allocator *v4; // esi@1 | 24 //Allocator *v4; // esi@1 |
25 unsigned int v5; // eax@7 | 25 unsigned int v5; // eax@7 |
26 void *result; // eax@8 | 26 void *result; // eax@8 |
27 unsigned int *pNumBuffersUsed; // ebx@12 | 27 unsigned int *pNumBuffersUsed; // ebx@12 |
28 unsigned int v8; // edi@15 | 28 unsigned int v8; // edi@15 |
29 char v9; // zf@15 | 29 char v9; // zf@15 |
30 int v10; // eax@16 | 30 int v10; // eax@16 |
31 void **v11; // ebx@19 | 31 void **v11; // ebx@19 |
32 void *v12; // eax@22 | 32 void *v12; // eax@22 |
33 unsigned int Size; // [sp+14h] [bp+Ch]@16 | 33 unsigned int Size; // [sp+14h] [bp+Ch]@16 |
34 | 34 |
35 v4 = this; | 35 //v4 = this; |
36 if ( pPrevPtrValue && !aborting_app ) | 36 if ( pPrevPtrValue && !aborting_app ) |
37 AbortWithError(); | 37 AbortWithError(); |
38 if ( !v4->bBigBufferAllocated && !aborting_app ) | 38 if ( !bBigBufferAllocated && !aborting_app ) |
39 AbortWithError(); | 39 AbortWithError(); |
40 v5 = uSize; | 40 v5 = uSize; |
41 if ( uSize ) | 41 if ( uSize ) |
42 { | 42 { |
43 if ( (uSize & 0x80000000u) != 0 && !aborting_app ) | 43 if ( (uSize & 0x80000000u) != 0 && !aborting_app ) |
44 { | 44 { |
45 AbortWithError(); | 45 AbortWithError(); |
46 v5 = uSize; | 46 v5 = uSize; |
47 } | 47 } |
48 pNumBuffersUsed = &v4->uNumBuffersUsed; | 48 pNumBuffersUsed = &uNumBuffersUsed; |
49 if ( v4->uNumBuffersUsed == 6000 && !aborting_app ) | 49 if (uNumBuffersUsed == 6000 && !aborting_app) |
50 { | 50 { |
51 AbortWithError(); | 51 AbortWithError(); |
52 v5 = uSize; | 52 v5 = uSize; |
53 } | 53 } |
54 v8 = *pNumBuffersUsed; | 54 v8 = *pNumBuffersUsed; |
55 v9 = v4->bUseBigBuffer == 0; | 55 v9 = bUseBigBuffer == 0; |
56 ++*pNumBuffersUsed; | 56 ++*pNumBuffersUsed; |
57 if ( v9 ) | 57 if ( v9 ) |
58 { | 58 { |
59 v12 = malloc(v5); | 59 v12 = malloc(v5); |
60 v11 = (void **)((char *)v4 + 4 * v8); | 60 v11 = &pMemoryBuffers[v8]; |
61 *v11 = v12; | 61 *v11 = v12; |
62 if ( v12 ) | 62 if ( v12 ) |
63 { | 63 { |
64 v4->uMemoryBuffersSizes[v8] = uSize; | 64 uMemoryBuffersSizes[v8] = uSize; |
65 } | 65 } |
66 else | 66 else |
67 { | 67 { |
68 if ( !aborting_app ) | 68 if ( !aborting_app ) |
69 AbortWithError(); | 69 AbortWithError(); |
72 else | 72 else |
73 { | 73 { |
74 LOBYTE(v5) = v5 & 0xFC; | 74 LOBYTE(v5) = v5 & 0xFC; |
75 v10 = v5 + 4; | 75 v10 = v5 + 4; |
76 Size = v10; | 76 Size = v10; |
77 if ( v10 + v4->uNextFreeOffsetInBigBuffer > v4->uBigBufferSizeAligned ) | 77 if ( v10 + uNextFreeOffsetInBigBuffer > uBigBufferSizeAligned ) |
78 { | 78 { |
79 printf("Id: %s Size: %i\n", pName, v10); | 79 printf("Id: %s Size: %i\n", pName, v10); |
80 CreateFileDump("Memory"); | 80 CreateFileDump("Memory"); |
81 if ( !aborting_app ) | 81 if ( !aborting_app ) |
82 AbortWithError(); | 82 AbortWithError(); |
83 } | 83 } |
84 v11 = (void **)((char *)v4 + 4 * v8); | 84 v11 = &pMemoryBuffers[v8]; |
85 *v11 = (char *)v4->pBigMemoryBuffer + v4->uNextFreeOffsetInBigBuffer; | 85 *v11 = (char *)pBigMemoryBuffer + uNextFreeOffsetInBigBuffer; |
86 v4->uMemoryBuffersSizes[v8] = Size; | 86 uMemoryBuffersSizes[v8] = Size; |
87 if ( pName ) | 87 if (pName) |
88 strncpy((char *)v4 + 4 * (3 * v8 + 12000), pName, 11u); | 88 strncpy(pMemoryBuffersNames[v8], pName, 11); |
89 v4->uNextFreeOffsetInBigBuffer += Size; | 89 uNextFreeOffsetInBigBuffer += Size; |
90 } | 90 } |
91 result = *v11; | 91 result = *v11; |
92 } | 92 } |
93 else | 93 else |
94 { | 94 { |