mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-18 15:11:51 +00:00
Clear quote memory after allocation
git-svn-id: https://svn.eduke32.com/eduke32@103 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
ee521c4d58
commit
225605f79a
3 changed files with 32 additions and 16 deletions
|
@ -7994,6 +7994,13 @@ void Shutdown( void )
|
|||
if(redefined_quotes[i] != NULL)
|
||||
Bfree(redefined_quotes[i]);
|
||||
}
|
||||
for(i=0;i<iGameVarCount;i++)
|
||||
{
|
||||
if(aGameVars[i].szLabel != NULL)
|
||||
Bfree(aGameVars[i].szLabel);
|
||||
if(aDefaultGameVars[i].szLabel != NULL)
|
||||
Bfree(aDefaultGameVars[i].szLabel);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1051,6 +1051,7 @@ void ReadGameVars(long fil)
|
|||
{
|
||||
kdfread(&(aGameVars[i]),sizeof(MATTGAMEVAR),1,fil);
|
||||
aGameVars[i].szLabel=Bmalloc(sizeof(char) * MAXVARLABEL);
|
||||
Bmemset(aGameVars[i].szLabel,0,MAXVARLABEL);
|
||||
kdfread(aGameVars[i].szLabel,sizeof(char) * MAXVARLABEL, 1, fil);
|
||||
}
|
||||
|
||||
|
@ -1305,14 +1306,20 @@ char AddGameVar(char *pszLabel, long lValue, unsigned long dwFlags)
|
|||
else
|
||||
{
|
||||
if(aGameVars[i].szLabel == NULL)
|
||||
{
|
||||
aGameVars[i].szLabel=Bmalloc(sizeof(char) * MAXVARLABEL);
|
||||
Bmemset(aGameVars[i].szLabel,0,MAXVARLABEL);
|
||||
}
|
||||
Bstrcpy(aGameVars[i].szLabel,pszLabel);
|
||||
aGameVars[i].dwFlags=dwFlags;
|
||||
aGameVars[i].lValue=lValue;
|
||||
if(!(dwFlags & GAMEVAR_FLAG_NODEFAULT))
|
||||
{
|
||||
if(aDefaultGameVars[i].szLabel == NULL)
|
||||
{
|
||||
aDefaultGameVars[i].szLabel=Bmalloc(sizeof(char) * MAXVARLABEL);
|
||||
Bmemset(aDefaultGameVars[i].szLabel,0,MAXVARLABEL);
|
||||
}
|
||||
Bstrcpy(aDefaultGameVars[i].szLabel,pszLabel);
|
||||
aDefaultGameVars[i].dwFlags=dwFlags;
|
||||
aDefaultGameVars[i].lValue=lValue;
|
||||
|
@ -4532,18 +4539,17 @@ repeatcase:
|
|||
error++;
|
||||
}
|
||||
|
||||
if (tw == CON_DEFINEQUOTE)
|
||||
if(fta_quotes[k] == NULL)
|
||||
fta_quotes[k] = Bmalloc(sizeof(char) * MAXQUOTELEN);
|
||||
if (!fta_quotes[k])
|
||||
{
|
||||
if(fta_quotes[k] == NULL)
|
||||
fta_quotes[k] = Bmalloc(sizeof(char) * MAXQUOTELEN);
|
||||
if (!fta_quotes[k])
|
||||
{
|
||||
fta_quotes[k] = NULL;
|
||||
Bsprintf(tempbuf,"Failed allocating %d byte quote text buffer.",sizeof(char) * MAXQUOTELEN);
|
||||
gameexit(tempbuf);
|
||||
}
|
||||
fta_quotes[k] = NULL;
|
||||
Bsprintf(tempbuf,"Failed allocating %d byte quote text buffer.",sizeof(char) * MAXQUOTELEN);
|
||||
gameexit(tempbuf);
|
||||
} else Bmemset(fta_quotes[k],0,MAXQUOTELEN);
|
||||
|
||||
if (tw == CON_DEFINEQUOTE)
|
||||
scriptptr--;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
||||
|
@ -4560,7 +4566,7 @@ repeatcase:
|
|||
redefined_quotes[redefined_quote_count] = NULL;
|
||||
Bsprintf(tempbuf,"Failed allocating %d byte quote text buffer.",sizeof(char) * MAXQUOTELEN);
|
||||
gameexit(tempbuf);
|
||||
}
|
||||
} else Bmemset(redefined_quotes[redefined_quote_count],0,MAXQUOTELEN);
|
||||
}
|
||||
|
||||
while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 )
|
||||
|
@ -5883,9 +5889,12 @@ void loadefs(char *filenam)
|
|||
initprintf("\nCompiled code size: %ld/%ld bytes\n",(unsigned)(scriptptr-script),MAXSCRIPTSIZE);
|
||||
initprintf("%ld/%ld labels, %d/%d variables\n",labelcnt,min((sizeof(sector)/sizeof(long)),(sizeof(sprite)/(1<<6))),iGameVarCount,MAXGAMEVARS);
|
||||
initprintf("%ld event definitions, %ld defined actors\n\n",j,k);
|
||||
for(i=0;i<124;i++)
|
||||
for(i=0;i<128;i++)
|
||||
if(fta_quotes[i] == NULL)
|
||||
{
|
||||
fta_quotes[i] = Bmalloc(sizeof(char) * MAXQUOTELEN);
|
||||
Bmemset(fta_quotes[i],0,MAXQUOTELEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3408,9 +3408,9 @@ char parse(void)
|
|||
insptr++;
|
||||
q = *insptr++;
|
||||
i = *insptr++;
|
||||
if(fta_quotes[q] != NULL && redefined_quotes[i] != NULL)
|
||||
Bstrcpy(fta_quotes[q],redefined_quotes[i]);
|
||||
else OSD_Printf("%s %d null quote %d %d\n",__FILE__,__LINE__,q,i);
|
||||
if(fta_quotes[q] == NULL || redefined_quotes[i] == NULL)
|
||||
OSD_Printf("%s %d null quote %d %d\n",__FILE__,__LINE__,q,i);
|
||||
else Bstrcpy(fta_quotes[q],redefined_quotes[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -4115,7 +4115,7 @@ SKIPJIBS:
|
|||
Bsprintf(fta_quotes[i],"%s",ud.user_name[j]);
|
||||
else
|
||||
Bsprintf(fta_quotes[i],"%d",j);
|
||||
}
|
||||
} else OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,i);
|
||||
break;
|
||||
case CON_QSTRCAT:
|
||||
if(fta_quotes[i] != NULL && fta_quotes[j] != NULL)
|
||||
|
|
Loading…
Reference in a new issue