Fix gamearray overallocation on 64-bit... was being allocated as (array size * sizeof(intptr_t)) when the struct actually contains a ptr to a block of int32_t

git-svn-id: https://svn.eduke32.com/eduke32@1964 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2011-08-12 15:40:28 +00:00
parent 0cb474f6be
commit b996f92c28
1 changed files with 5 additions and 5 deletions

View File

@ -159,8 +159,8 @@ int32_t Gv_ReadSave(int32_t fil, int32_t newbehav)
if (kdfread(aGameArrays[i].szLabel,sizeof(uint8_t) * MAXARRAYLABEL, 1, fil) != 1) goto corrupt;
hash_add(&h_arrays, aGameArrays[i].szLabel, i, 1);
aGameArrays[i].plValues=Bcalloc(aGameArrays[i].size,sizeof(intptr_t));
if (kdfread(aGameArrays[i].plValues,sizeof(intptr_t) * aGameArrays[i].size, 1, fil) < 1) goto corrupt;
aGameArrays[i].plValues=Bcalloc(aGameArrays[i].size,sizeof(int32_t));
if (kdfread(aGameArrays[i].plValues,sizeof(int32_t) * aGameArrays[i].size, 1, fil) < 1) goto corrupt;
}
// Bsprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__);
@ -273,7 +273,7 @@ void Gv_WriteSave(FILE *fil, int32_t newbehav)
{
dfwrite(&(aGameArrays[i]),sizeof(gamearray_t),1,fil);
dfwrite(aGameArrays[i].szLabel,sizeof(uint8_t) * MAXARRAYLABEL, 1, fil);
dfwrite(aGameArrays[i].plValues,sizeof(intptr_t) * aGameArrays[i].size, 1, fil);
dfwrite(aGameArrays[i].plValues,sizeof(int32_t) * aGameArrays[i].size, 1, fil);
}
G_Util_PtrToIdx(apScriptGameEvent, MAXGAMEEVENTS, script, P2I_FWD_NON0);
@ -411,10 +411,10 @@ int32_t Gv_NewArray(const char *pszLabel, int32_t asize)
i = g_gameArrayCount;
if (aGameArrays[i].szLabel == NULL)
aGameArrays[i].szLabel=Bcalloc(MAXVARLABEL,sizeof(uint8_t));
aGameArrays[i].szLabel=(char *)Bcalloc(MAXVARLABEL,sizeof(uint8_t));
if (aGameArrays[i].szLabel != pszLabel)
Bstrcpy(aGameArrays[i].szLabel,pszLabel);
aGameArrays[i].plValues=Bcalloc(asize,sizeof(intptr_t));
aGameArrays[i].plValues=(int32_t *)Bcalloc(asize,sizeof(int32_t));
aGameArrays[i].size=asize;
aGameArrays[i].bReset=0;
g_gameArrayCount++;