mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 02:30:46 +00:00
Remove NULL checks before calling free(): they are unnecessary as per the C standard. Other cleanup includes factoring code into DO_FREE_AND_NULL() macros.
git-svn-id: https://svn.eduke32.com/eduke32@5352 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
1ca367960f
commit
a557eedf7e
41 changed files with 176 additions and 305 deletions
|
@ -953,11 +953,11 @@ FORCE_INLINE void *xaligned_malloc(const bsize_t alignment, const bsize_t size)
|
|||
#endif
|
||||
|
||||
#define DO_FREE_AND_NULL(var) do { \
|
||||
if (var != NULL) { Bfree(var); var = NULL; } \
|
||||
Bfree(var); (var) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define ALIGNED_FREE_AND_NULL(var) do { \
|
||||
if (var != NULL) { Baligned_free(var); var = NULL; } \
|
||||
Baligned_free(var); (var) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define MAYBE_FCLOSE_AND_NULL(fileptr) do { \
|
||||
|
|
|
@ -718,9 +718,9 @@ int32_t app_main(int32_t argc, const char **argv)
|
|||
initprintf("Definitions file \"%s\" loaded.\n",defsfile);
|
||||
|
||||
for (i=0; i < g_defModulesNum; ++i)
|
||||
Bfree (g_defModules[i]);
|
||||
Bfree (g_defModules);
|
||||
g_defModules = NULL; // be defensive...
|
||||
Bfree(g_defModules[i]);
|
||||
DO_FREE_AND_NULL(g_defModules);
|
||||
g_defModulesNum = 0;
|
||||
|
||||
if (E_PostInit())
|
||||
M32_FatalEngineError();
|
||||
|
@ -733,9 +733,9 @@ int32_t app_main(int32_t argc, const char **argv)
|
|||
initprintf("There was an error loading the sprite clipping map (status %d).\n", k);
|
||||
|
||||
for (i=0; i < g_clipMapFilesNum; ++i)
|
||||
Bfree (g_clipMapFiles[i]);
|
||||
Bfree (g_clipMapFiles);
|
||||
g_clipMapFiles = NULL;
|
||||
Bfree(g_clipMapFiles[i]);
|
||||
DO_FREE_AND_NULL(g_clipMapFiles);
|
||||
g_clipMapFilesNum = 0;
|
||||
#endif
|
||||
|
||||
taglab_init();
|
||||
|
@ -2626,8 +2626,7 @@ static int32_t backup_drawn_walls(int32_t restore)
|
|||
}
|
||||
}
|
||||
|
||||
Bfree(tmpwall);
|
||||
tmpwall = NULL;
|
||||
DO_FREE_AND_NULL(tmpwall);
|
||||
|
||||
ovh.bak_wallsdrawn = 0;
|
||||
}
|
||||
|
@ -6379,8 +6378,7 @@ end_point_dragging:
|
|||
}
|
||||
}
|
||||
|
||||
if (origframe)
|
||||
Bfree(origframe);
|
||||
Bfree(origframe);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -6406,11 +6404,7 @@ end_point_dragging:
|
|||
if (!bakframe_fillandfade(&origframe, i, "Use this as second joining sector? (Y/N)"))
|
||||
continue;
|
||||
|
||||
if (origframe)
|
||||
{
|
||||
Bfree(origframe);
|
||||
origframe = NULL;
|
||||
}
|
||||
DO_FREE_AND_NULL(origframe);
|
||||
}
|
||||
|
||||
joinsector[1] = i;
|
||||
|
@ -7735,8 +7729,7 @@ end_batch_insert_points:
|
|||
printmessage16("Sector deleted.");
|
||||
}
|
||||
|
||||
if (origframe)
|
||||
Bfree(origframe);
|
||||
Bfree(origframe);
|
||||
|
||||
#ifdef YAX_ENABLE
|
||||
for (j=0; j<numsectors; j++)
|
||||
|
|
|
@ -642,8 +642,7 @@ int32_t openfrompath(const char *fn, int32_t flags, int32_t mode)
|
|||
|
||||
int32_t h = openfrompath_internal(fn, &pfn, flags, mode);
|
||||
|
||||
if (pfn)
|
||||
Bfree(pfn);
|
||||
Bfree(pfn);
|
||||
|
||||
return h;
|
||||
}
|
||||
|
@ -779,8 +778,7 @@ int32_t initgroupfile(const char *filename)
|
|||
Bfree(zfn);
|
||||
}
|
||||
#else
|
||||
if (zfn)
|
||||
Bfree(zfn);
|
||||
Bfree(zfn);
|
||||
#endif
|
||||
|
||||
// check if GRP
|
||||
|
@ -1123,8 +1121,7 @@ int32_t kopen4load(const char *filename, char searchfirst)
|
|||
|
||||
int32_t h = kopen_internal(filename, &lastpfn, searchfirst, 1, 1, newhandle, filegrp, filehan, filepos);
|
||||
|
||||
if (lastpfn)
|
||||
Bfree(lastpfn);
|
||||
Bfree(lastpfn);
|
||||
|
||||
return h;
|
||||
}
|
||||
|
|
|
@ -32,8 +32,7 @@ char *g_defNamePtr = NULL;
|
|||
|
||||
void clearDefNamePtr(void)
|
||||
{
|
||||
if (g_defNamePtr != NULL)
|
||||
Bfree(g_defNamePtr);
|
||||
Bfree(g_defNamePtr);
|
||||
// g_defNamePtr assumed to be assigned to right after
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ void set_memerr_handler(void(*handlerfunc)(int32_t, const char *, const char *))
|
|||
void Bassert(int expr) { assert(expr); }
|
||||
int32_t Brand(void) { return rand(); }
|
||||
void *Bmalloc(bsize_t size) { return malloc(size); }
|
||||
void Bfree(void *ptr) { Bfree(ptr); }
|
||||
void Bfree(void *ptr) { free(ptr); }
|
||||
|
||||
int32_t Bopen(const char *pathname, int32_t flags, uint32_t mode)
|
||||
{
|
||||
|
|
|
@ -1817,8 +1817,8 @@ int32_t clipmapinfo_load(void)
|
|||
pictoidx[i]=tempictoidx[i];
|
||||
}
|
||||
|
||||
Bfree(loadsprite); loadsprite=NULL;
|
||||
Bfree(tempictoidx); tempictoidx=NULL;
|
||||
DO_FREE_AND_NULL(loadsprite);
|
||||
DO_FREE_AND_NULL(tempictoidx);
|
||||
|
||||
// don't let other code be distracted by the temporary map we constructed
|
||||
numsectors = 0;
|
||||
|
@ -9371,7 +9371,7 @@ void uninitengine(void)
|
|||
paletteloaded = 0;
|
||||
|
||||
for (int i=0; i<MAXPALOOKUPS; i++)
|
||||
if (palookup[i] != NULL && (i==0 || palookup[i] != palookup[0]))
|
||||
if (i==0 || palookup[i] != palookup[0])
|
||||
{
|
||||
// Take care of handling aliased ^^^ cases!
|
||||
Bfree(palookup[i]);
|
||||
|
@ -9379,13 +9379,11 @@ void uninitengine(void)
|
|||
Bmemset(palookup, 0, sizeof(palookup));
|
||||
|
||||
for (int i=0; i<MAXBLENDTABS; i++)
|
||||
if (blendtable[i] != NULL)
|
||||
Bfree(blendtable[i]);
|
||||
Bfree(blendtable[i]);
|
||||
Bmemset(blendtable, 0, sizeof(blendtable));
|
||||
|
||||
for (int i=1; i<MAXBASEPALS; i++)
|
||||
if (basepaltable[i] != NULL)
|
||||
Bfree(basepaltable[i]);
|
||||
Bfree(basepaltable[i]);
|
||||
Bmemset(basepaltable, 0, sizeof(basepaltable));
|
||||
basepaltable[0] = palette;
|
||||
|
||||
|
@ -9399,12 +9397,11 @@ void uninitengine(void)
|
|||
|
||||
for (int i = 0; i < num_usermaphacks; i++)
|
||||
{
|
||||
if (usermaphacks[i].mhkfile)
|
||||
Bfree(usermaphacks[i].mhkfile);
|
||||
if (usermaphacks[i].title)
|
||||
Bfree(usermaphacks[i].title);
|
||||
Bfree(usermaphacks[i].mhkfile);
|
||||
Bfree(usermaphacks[i].title);
|
||||
}
|
||||
Bfree(usermaphacks);
|
||||
DO_FREE_AND_NULL(usermaphacks);
|
||||
num_usermaphacks = 0;
|
||||
|
||||
DO_FREE_AND_NULL(multipsky);
|
||||
DO_FREE_AND_NULL(multipskytile);
|
||||
|
@ -11758,8 +11755,7 @@ static void initsmost(void)
|
|||
|
||||
for (i = 0; i < (signed)ARRAY_SIZE(dynarray); i++)
|
||||
{
|
||||
if (*dynarray[i].ptr)
|
||||
Baligned_free(*dynarray[i].ptr);
|
||||
Baligned_free(*dynarray[i].ptr);
|
||||
|
||||
*dynarray[i].ptr = Xaligned_alloc(16, dynarray[i].size);
|
||||
}
|
||||
|
@ -11846,8 +11842,7 @@ int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t da
|
|||
swallf = (float *) Xrealloc(swallf, xdim * sizeof(float));
|
||||
#endif
|
||||
|
||||
if (lookups != NULL)
|
||||
Bfree(lookups);
|
||||
Bfree(lookups);
|
||||
|
||||
j = ydim*4; //Leave room for horizlookup&horizlookup2
|
||||
lookups = (int32_t *)Xmalloc(2*j*sizeof(lookups[0]));
|
||||
|
@ -18491,18 +18486,13 @@ void hash_free(hashtable_t *t)
|
|||
hashitem_t * const tmp = cur;
|
||||
cur = cur->next;
|
||||
|
||||
if (tmp->string)
|
||||
{
|
||||
Bfree(tmp->string);
|
||||
tmp->string = NULL;
|
||||
}
|
||||
Bfree(tmp->string);
|
||||
Bfree(tmp);
|
||||
num++;
|
||||
}
|
||||
} while (--remaining >= 0);
|
||||
|
||||
Bfree(t->items);
|
||||
t->items = 0;
|
||||
DO_FREE_AND_NULL(t->items);
|
||||
}
|
||||
|
||||
// djb3 algorithm
|
||||
|
|
|
@ -726,8 +726,7 @@ int32_t unloadgldriver(void)
|
|||
if (!hGLDLL) return 0;
|
||||
#endif
|
||||
|
||||
Bfree(gldriver);
|
||||
gldriver = NULL;
|
||||
DO_FREE_AND_NULL(gldriver);
|
||||
|
||||
#if !defined RENDERTYPESDL && defined _WIN32
|
||||
FreeLibrary(hGLDLL);
|
||||
|
@ -1115,8 +1114,7 @@ int32_t unloadglulibrary(void)
|
|||
if (!hGLUDLL) return 0;
|
||||
#endif
|
||||
|
||||
Bfree(glulibrary);
|
||||
glulibrary = NULL;
|
||||
DO_FREE_AND_NULL(glulibrary);
|
||||
|
||||
#if defined _WIN32
|
||||
FreeLibrary(hGLUDLL);
|
||||
|
|
|
@ -94,14 +94,11 @@ void hicinit(void)
|
|||
if (hr->skybox)
|
||||
{
|
||||
for (j=5; j>=0; j--)
|
||||
if (hr->skybox->face[j])
|
||||
Bfree(hr->skybox->face[j]);
|
||||
Bfree(hr->skybox->face[j]);
|
||||
Bfree(hr->skybox);
|
||||
}
|
||||
|
||||
if (hr->filename)
|
||||
Bfree(hr->filename);
|
||||
|
||||
Bfree(hr->filename);
|
||||
Bfree(hr);
|
||||
|
||||
hr = next;
|
||||
|
@ -160,7 +157,7 @@ int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float
|
|||
else hrn = hr;
|
||||
|
||||
// store into hicreplc the details for this replacement
|
||||
if (hrn->filename) Bfree(hrn->filename);
|
||||
Bfree(hrn->filename);
|
||||
|
||||
hrn->filename = Xstrdup(filen);
|
||||
hrn->alphacut = min(alphacut,1.0);
|
||||
|
@ -265,13 +262,12 @@ int32_t hicclearsubst(int32_t picnum, int32_t palnum)
|
|||
|
||||
if (!hr) return 0;
|
||||
|
||||
if (hr->filename) Bfree(hr->filename);
|
||||
Bfree(hr->filename);
|
||||
if (hr->skybox)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=5; i>=0; i--)
|
||||
if (hr->skybox->face[i])
|
||||
Bfree(hr->skybox->face[i]);
|
||||
Bfree(hr->skybox->face[i]);
|
||||
Bfree(hr->skybox);
|
||||
}
|
||||
|
||||
|
|
|
@ -1400,9 +1400,9 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength,
|
|||
kfileptr += leng;
|
||||
break;
|
||||
case 0xda:
|
||||
if ((xdim <= 0) || (ydim <= 0)) { if (dctbuf) Bfree(dctbuf); return(-1); }
|
||||
if ((xdim <= 0) || (ydim <= 0)) { Bfree(dctbuf); return(-1); }
|
||||
|
||||
lnumcomponents = (int32_t)(*kfileptr++); if (!lnumcomponents) { if (dctbuf) Bfree(dctbuf); return(-1); }
|
||||
lnumcomponents = (int32_t)(*kfileptr++); if (!lnumcomponents) { Bfree(dctbuf); return(-1); }
|
||||
if (lnumcomponents > 1) kcoltype = 2;
|
||||
for (z=0; z<lnumcomponents; z++)
|
||||
{
|
||||
|
@ -2465,7 +2465,7 @@ static int32_t kzcheckhash(const char *filnam, char **zipnam, int32_t *fileoffs,
|
|||
|
||||
void kzuninit()
|
||||
{
|
||||
if (kzhashbuf) { Bfree(kzhashbuf); kzhashbuf = 0; }
|
||||
DO_FREE_AND_NULL(kzhashbuf);
|
||||
kzhashpos = kzhashsiz = 0; kzdirnamhead = -1;
|
||||
}
|
||||
|
||||
|
@ -3074,11 +3074,8 @@ void kpzdecode(int32_t const leng, intptr_t * const pic, int32_t * const bpl, in
|
|||
|
||||
if (kprender(kpzbuf, leng, *pic, *bpl, *xsiz, *ysiz) < 0)
|
||||
{
|
||||
if (*pic)
|
||||
{
|
||||
Bfree((void *) *pic);
|
||||
*pic = 0;
|
||||
}
|
||||
Bfree((void *) *pic);
|
||||
*pic = (intptr_t)NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,8 +106,7 @@ int L_CreateState(L_State *estate, const char *name, void (*StateSetupFunc)(lua_
|
|||
|
||||
if (!estate->L)
|
||||
{
|
||||
Bfree(estate->name);
|
||||
estate->name = NULL;
|
||||
DO_FREE_AND_NULL(estate->name);
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
@ -131,8 +130,7 @@ void L_DestroyState(L_State *estate)
|
|||
if (!L_IsInitialized(estate))
|
||||
return;
|
||||
|
||||
Bfree(estate->name);
|
||||
estate->name = NULL;
|
||||
DO_FREE_AND_NULL(estate->name);
|
||||
|
||||
lua_close(estate->L);
|
||||
estate->L = NULL;
|
||||
|
|
|
@ -111,8 +111,7 @@ void md_freevbos()
|
|||
{
|
||||
// OSD_Printf("freeing model %d vbo\n",i);
|
||||
bglDeleteBuffersARB(m->head.numsurfs, m->vbos);
|
||||
Bfree(m->vbos);
|
||||
m->vbos = NULL;
|
||||
DO_FREE_AND_NULL(m->vbos);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,7 +130,7 @@ void freeallmodels()
|
|||
if (models)
|
||||
{
|
||||
for (i=0; i<nextmodelid; i++) mdfree(models[i]);
|
||||
Bfree(models); models = NULL;
|
||||
DO_FREE_AND_NULL(models);
|
||||
nummodelsalloced = 0;
|
||||
nextmodelid = 0;
|
||||
}
|
||||
|
@ -144,8 +143,7 @@ void freeallmodels()
|
|||
|
||||
if (vertlist)
|
||||
{
|
||||
Bfree(vertlist);
|
||||
vertlist = NULL;
|
||||
DO_FREE_AND_NULL(vertlist);
|
||||
allocmodelverts = maxmodelverts = 0;
|
||||
allocmodeltris = maxmodeltris = 0;
|
||||
}
|
||||
|
@ -512,7 +510,7 @@ int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32
|
|||
if (!skl) m->skinmap = sk;
|
||||
else skl->next = sk;
|
||||
}
|
||||
else if (sk->fn) Bfree(sk->fn);
|
||||
else Bfree(sk->fn);
|
||||
|
||||
sk->palette = (uint8_t)palnum;
|
||||
sk->flags = (uint8_t)flags;
|
||||
|
@ -2505,22 +2503,21 @@ static void md3free(md3model_t *m)
|
|||
}
|
||||
Bfree(m->head.surfs);
|
||||
}
|
||||
if (m->head.tags) Bfree(m->head.tags);
|
||||
if (m->head.frames) Bfree(m->head.frames);
|
||||
Bfree(m->head.tags);
|
||||
Bfree(m->head.frames);
|
||||
|
||||
if (m->texid) Bfree(m->texid);
|
||||
Bfree(m->texid);
|
||||
|
||||
if (m->muladdframes) Bfree(m->muladdframes);
|
||||
Bfree(m->muladdframes);
|
||||
|
||||
if (m->indexes) Bfree(m->indexes);
|
||||
if (m->vindexes) Bfree(m->vindexes);
|
||||
if (m->maxdepths) Bfree(m->maxdepths);
|
||||
Bfree(m->indexes);
|
||||
Bfree(m->vindexes);
|
||||
Bfree(m->maxdepths);
|
||||
|
||||
if (m->vbos)
|
||||
{
|
||||
bglDeleteBuffersARB(m->head.numsurfs, m->vbos);
|
||||
Bfree(m->vbos);
|
||||
m->vbos = NULL;
|
||||
DO_FREE_AND_NULL(m->vbos);
|
||||
}
|
||||
|
||||
Bfree(m);
|
||||
|
|
|
@ -214,7 +214,7 @@ int32_t OSD_Exec(const char *szScript)
|
|||
if (!err || err == 3) // no error message for blank file
|
||||
OSD_Printf("Error executing \"%s\"!\n", szScript);
|
||||
if (i != -1) kclose(i);
|
||||
if (buf != NULL) Bfree(buf);
|
||||
Bfree(buf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1981,9 +1981,9 @@ static symbol_t *addnewsymbol(const char *name)
|
|||
}
|
||||
}
|
||||
hash_add(&h_osd, name, osd->numsymbols, 1);
|
||||
name = Bstrtolower(Xstrdup(name));
|
||||
hash_add(&h_osd, name, osd->numsymbols, 1);
|
||||
Bfree((void *)name);
|
||||
char * const newname = Bstrtolower(Xstrdup(name));
|
||||
hash_add(&h_osd, newname, osd->numsymbols, 1);
|
||||
Bfree(newname);
|
||||
osd->symbptrs[osd->numsymbols++] = newsymb;
|
||||
return newsymb;
|
||||
}
|
||||
|
|
|
@ -884,8 +884,7 @@ void polymer_uninit(void)
|
|||
while (j < MAXPALOOKUPS)
|
||||
{
|
||||
// if (prhighpalookups[i][j].data) {
|
||||
// Bfree(prhighpalookups[i][j].data);
|
||||
// prhighpalookups[i][j].data = NULL;
|
||||
// DO_FREE_AND_NULL(prhighpalookups[i][j].data);
|
||||
// }
|
||||
if (prhighpalookups[i][j].map) {
|
||||
bglDeleteTextures(1, &prhighpalookups[i][j].map);
|
||||
|
@ -1271,10 +1270,8 @@ void polymer_drawmasks(void)
|
|||
// Both the top-level game drawrooms and the recursive internal passes
|
||||
// should be accounted for here. If these free cause corruption, there's
|
||||
// an accounting bug somewhere.
|
||||
Bfree(cursectormaskcount);
|
||||
cursectormaskcount = NULL;
|
||||
Bfree(cursectormasks);
|
||||
cursectormasks = NULL;
|
||||
DO_FREE_AND_NULL(cursectormaskcount);
|
||||
DO_FREE_AND_NULL(cursectormasks);
|
||||
}
|
||||
|
||||
bglDisable(GL_CULL_FACE);
|
||||
|
@ -2456,18 +2453,17 @@ static void polymer_freeboard(void)
|
|||
{
|
||||
if (prsectors[i])
|
||||
{
|
||||
if (prsectors[i]->verts) Bfree(prsectors[i]->verts);
|
||||
if (prsectors[i]->floor.buffer) Bfree(prsectors[i]->floor.buffer);
|
||||
if (prsectors[i]->ceil.buffer) Bfree(prsectors[i]->ceil.buffer);
|
||||
if (prsectors[i]->floor.indices) Bfree(prsectors[i]->floor.indices);
|
||||
if (prsectors[i]->ceil.indices) Bfree(prsectors[i]->ceil.indices);
|
||||
Bfree(prsectors[i]->verts);
|
||||
Bfree(prsectors[i]->floor.buffer);
|
||||
Bfree(prsectors[i]->ceil.buffer);
|
||||
Bfree(prsectors[i]->floor.indices);
|
||||
Bfree(prsectors[i]->ceil.indices);
|
||||
if (prsectors[i]->ceil.vbo) bglDeleteBuffersARB(1, &prsectors[i]->ceil.vbo);
|
||||
if (prsectors[i]->ceil.ivbo) bglDeleteBuffersARB(1, &prsectors[i]->ceil.ivbo);
|
||||
if (prsectors[i]->floor.vbo) bglDeleteBuffersARB(1, &prsectors[i]->floor.vbo);
|
||||
if (prsectors[i]->floor.ivbo) bglDeleteBuffersARB(1, &prsectors[i]->floor.ivbo);
|
||||
|
||||
Bfree(prsectors[i]);
|
||||
prsectors[i] = NULL;
|
||||
DO_FREE_AND_NULL(prsectors[i]);
|
||||
}
|
||||
|
||||
i++;
|
||||
|
@ -2478,18 +2474,17 @@ static void polymer_freeboard(void)
|
|||
{
|
||||
if (prwalls[i])
|
||||
{
|
||||
if (prwalls[i]->bigportal) Bfree(prwalls[i]->bigportal);
|
||||
if (prwalls[i]->mask.buffer) Bfree(prwalls[i]->mask.buffer);
|
||||
if (prwalls[i]->over.buffer) Bfree(prwalls[i]->over.buffer);
|
||||
//if (prwalls[i]->cap) Bfree(prwalls[i]->cap);
|
||||
if (prwalls[i]->wall.buffer) Bfree(prwalls[i]->wall.buffer);
|
||||
Bfree(prwalls[i]->bigportal);
|
||||
Bfree(prwalls[i]->mask.buffer);
|
||||
Bfree(prwalls[i]->over.buffer);
|
||||
// Bfree(prwalls[i]->cap);
|
||||
Bfree(prwalls[i]->wall.buffer);
|
||||
if (prwalls[i]->wall.vbo) bglDeleteBuffersARB(1, &prwalls[i]->wall.vbo);
|
||||
if (prwalls[i]->over.vbo) bglDeleteBuffersARB(1, &prwalls[i]->over.vbo);
|
||||
if (prwalls[i]->mask.vbo) bglDeleteBuffersARB(1, &prwalls[i]->mask.vbo);
|
||||
if (prwalls[i]->stuffvbo) bglDeleteBuffersARB(1, &prwalls[i]->stuffvbo);
|
||||
|
||||
Bfree(prwalls[i]);
|
||||
prwalls[i] = NULL;
|
||||
DO_FREE_AND_NULL(prwalls[i]);
|
||||
}
|
||||
|
||||
i++;
|
||||
|
@ -2500,10 +2495,9 @@ static void polymer_freeboard(void)
|
|||
{
|
||||
if (prsprites[i])
|
||||
{
|
||||
if (prsprites[i]->plane.buffer) Bfree(prsprites[i]->plane.buffer);
|
||||
Bfree(prsprites[i]->plane.buffer);
|
||||
if (prsprites[i]->plane.vbo) bglDeleteBuffersARB(1, &prsprites[i]->plane.vbo);
|
||||
Bfree(prsprites[i]);
|
||||
prsprites[i] = NULL;
|
||||
DO_FREE_AND_NULL(prsprites[i]);
|
||||
}
|
||||
|
||||
i++;
|
||||
|
@ -6196,8 +6190,7 @@ static void polymer_initrendertargets(int32_t count)
|
|||
bglDeleteFramebuffersEXT(1, &prrts[i].fbo);
|
||||
prrts[i].fbo = 0;
|
||||
}
|
||||
Bfree(prrts);
|
||||
prrts = NULL;
|
||||
DO_FREE_AND_NULL(prrts);
|
||||
}
|
||||
|
||||
ocount = 0;
|
||||
|
|
|
@ -313,11 +313,9 @@ scriptfile *scriptfile_fromstring(const char *string)
|
|||
void scriptfile_close(scriptfile *sf)
|
||||
{
|
||||
if (!sf) return;
|
||||
if (sf->lineoffs) Bfree(sf->lineoffs);
|
||||
if (sf->textbuf) Bfree(sf->textbuf);
|
||||
if (sf->filename) Bfree(sf->filename);
|
||||
sf->textbuf = NULL;
|
||||
sf->filename = NULL;
|
||||
Bfree(sf->lineoffs);
|
||||
Bfree(sf->textbuf);
|
||||
Bfree(sf->filename);
|
||||
Bfree(sf);
|
||||
}
|
||||
|
||||
|
@ -398,8 +396,7 @@ int32_t scriptfile_addsymbolvalue(char *name, int32_t val)
|
|||
|
||||
void scriptfile_clearsymbols(void)
|
||||
{
|
||||
if (symbtab) Bfree(symbtab);
|
||||
symbtab = NULL;
|
||||
DO_FREE_AND_NULL(symbtab);
|
||||
symbtablength = 0;
|
||||
symbtaballoclength = 0;
|
||||
}
|
||||
|
|
|
@ -208,8 +208,7 @@ void texcache_freeptrs(void)
|
|||
texcache.iptrs[ii] = NULL;
|
||||
}
|
||||
|
||||
Bfree(texcache.iptrs[i]);
|
||||
texcache.iptrs[i] = NULL;
|
||||
DO_FREE_AND_NULL(texcache.iptrs[i]);
|
||||
}
|
||||
|
||||
DO_FREE_AND_NULL(texcache.iptrs);
|
||||
|
|
|
@ -120,10 +120,7 @@ unsigned Bstring::length(void) const { return Bstrlen(data); }
|
|||
|
||||
void Bstring::clear(void)
|
||||
{
|
||||
if (data != NULL)
|
||||
Bfree(data);
|
||||
|
||||
data = NULL;
|
||||
DO_FREE_AND_NULL(data);
|
||||
}
|
||||
|
||||
////////// arttool //////////
|
||||
|
|
|
@ -464,7 +464,7 @@ int32_t WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, in
|
|||
|
||||
win_close();
|
||||
|
||||
if (argvbuf) Bfree(argvbuf);
|
||||
Bfree(argvbuf);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -1158,18 +1158,18 @@ static void UninitDirectInput(void)
|
|||
|
||||
if (axisdefs)
|
||||
{
|
||||
for (i=joynumaxes-1; i>=0; i--) if (axisdefs[i].name) Bfree((void *)axisdefs[i].name);
|
||||
Bfree(axisdefs); axisdefs = NULL;
|
||||
for (i=joynumaxes-1; i>=0; i--) Bfree(axisdefs[i].name);
|
||||
DO_FREE_AND_NULL(axisdefs);
|
||||
}
|
||||
if (buttondefs)
|
||||
{
|
||||
for (i=joynumbuttons-1; i>=0; i--) if (buttondefs[i].name) Bfree((void *)buttondefs[i].name);
|
||||
Bfree(buttondefs); buttondefs = NULL;
|
||||
for (i=joynumbuttons-1; i>=0; i--) Bfree(buttondefs[i].name);
|
||||
DO_FREE_AND_NULL(buttondefs);
|
||||
}
|
||||
if (hatdefs)
|
||||
{
|
||||
for (i=joynumhats-1; i>=0; i--) if (hatdefs[i].name) Bfree((void *)hatdefs[i].name);
|
||||
Bfree(hatdefs); hatdefs = NULL;
|
||||
for (i=joynumhats-1; i>=0; i--) Bfree(hatdefs[i].name);
|
||||
DO_FREE_AND_NULL(hatdefs);
|
||||
}
|
||||
|
||||
if (di_inputevt)
|
||||
|
@ -2429,11 +2429,10 @@ static void ReleaseDirectDrawSurfaces(void)
|
|||
lpDDSPrimary = NULL;
|
||||
}
|
||||
|
||||
if (lpOffscreen)
|
||||
// if (lpOffscreen)
|
||||
{
|
||||
// initprintf(" - Freeing offscreen buffer\n");
|
||||
Bfree(lpOffscreen);
|
||||
lpOffscreen = NULL;
|
||||
DO_FREE_AND_NULL(lpOffscreen);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -146,8 +146,7 @@ int32_t animvpx_uninit_codec(animvpx_codec_ctx *codec)
|
|||
if (codec->initstate <= 0)
|
||||
return 2;
|
||||
|
||||
Bfree(codec->pic);
|
||||
codec->pic = NULL;
|
||||
DO_FREE_AND_NULL(codec->pic);
|
||||
|
||||
if (vpx_codec_destroy(&codec->codec))
|
||||
{
|
||||
|
|
|
@ -8352,8 +8352,7 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
|
|||
}
|
||||
else
|
||||
{
|
||||
Bfree(testplay_addparam);
|
||||
testplay_addparam = NULL;
|
||||
DO_FREE_AND_NULL(testplay_addparam);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8501,11 +8500,7 @@ static int32_t osdcmd_testplay_addparam(const osdfuncparm_t *parm)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (testplay_addparam)
|
||||
{
|
||||
Bfree(testplay_addparam);
|
||||
testplay_addparam = NULL;
|
||||
}
|
||||
DO_FREE_AND_NULL(testplay_addparam);
|
||||
}
|
||||
|
||||
return OSDCMD_OK;
|
||||
|
@ -8829,8 +8824,7 @@ static void SaveInHistory(const char *commandstr)
|
|||
|
||||
if (dosave)
|
||||
{
|
||||
if (scripthist[scripthistend])
|
||||
Bfree(scripthist[scripthistend]);
|
||||
Bfree(scripthist[scripthistend]);
|
||||
scripthist[scripthistend] = Xstrdup(commandstr);
|
||||
scripthistend++;
|
||||
scripthistend %= SCRIPTHISTSIZ;
|
||||
|
@ -9552,10 +9546,8 @@ static int32_t loadtilegroups(const char *fn)
|
|||
|
||||
for (i=0; i<tile_groups; i++)
|
||||
{
|
||||
if (s_TileGroups[i].pIds)
|
||||
Bfree(s_TileGroups[i].pIds);
|
||||
if (s_TileGroups[i].szText)
|
||||
Bfree(s_TileGroups[i].szText);
|
||||
Bfree(s_TileGroups[i].pIds);
|
||||
Bfree(s_TileGroups[i].szText);
|
||||
Bmemcpy(&s_TileGroups[i], &blank, sizeof(blank));
|
||||
}
|
||||
tile_groups = 0;
|
||||
|
@ -9735,8 +9727,7 @@ static int32_t parseconsounds(scriptfile *script)
|
|||
{
|
||||
BAD:
|
||||
Bfree(definedname);
|
||||
Bfree(g_sounds[sndnum].filename);
|
||||
g_sounds[sndnum].filename = NULL;
|
||||
DO_FREE_AND_NULL(g_sounds[sndnum].filename);
|
||||
num_invalidsounds++;
|
||||
break;
|
||||
}
|
||||
|
@ -9794,7 +9785,8 @@ static int32_t loadconsounds(const char *fn)
|
|||
parseconsounds_include(g_scriptModules[i], NULL, "null");
|
||||
Bfree(g_scriptModules[i]);
|
||||
}
|
||||
Bfree(g_scriptModules);
|
||||
DO_FREE_AND_NULL(g_scriptModules);
|
||||
g_scriptModulesNum = 0;
|
||||
|
||||
if (ret < 0)
|
||||
initprintf("There was an error parsing \"%s\".\n", fn);
|
||||
|
@ -9951,13 +9943,11 @@ void ExtUnInit(void)
|
|||
#if 0
|
||||
for (i = MAX_TILE_GROUPS-1; i >= 0; i--)
|
||||
{
|
||||
if (s_TileGroups[i].pIds != NULL)
|
||||
Bfree(s_TileGroups[i].pIds);
|
||||
if (s_TileGroups[i].szText != NULL)
|
||||
Bfree(s_TileGroups[i].szText);
|
||||
Bfree(s_TileGroups[i].pIds);
|
||||
Bfree(s_TileGroups[i].szText);
|
||||
}
|
||||
for (i = numhelppages-1; i >= 0; i--) Bfree(helppage[i]);
|
||||
if (helppage) Bfree(helppage);
|
||||
Bfree(helppage);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -46,15 +46,13 @@ char *g_scriptNamePtr = NULL;
|
|||
|
||||
void clearGrpNamePtr(void)
|
||||
{
|
||||
if (g_grpNamePtr != NULL)
|
||||
Bfree(g_grpNamePtr);
|
||||
Bfree(g_grpNamePtr);
|
||||
// g_grpNamePtr assumed to be assigned to right after
|
||||
}
|
||||
|
||||
void clearScriptNamePtr(void)
|
||||
{
|
||||
if (g_scriptNamePtr != NULL)
|
||||
Bfree(g_scriptNamePtr);
|
||||
Bfree(g_scriptNamePtr);
|
||||
// g_scriptNamePtr assumed to be assigned to right after
|
||||
}
|
||||
|
||||
|
|
|
@ -10844,36 +10844,36 @@ static void G_Cleanup(void)
|
|||
|
||||
for (i=(MAXLEVELS*(MAXVOLUMES+1))-1; i>=0; i--) // +1 volume for "intro", "briefing" music
|
||||
{
|
||||
if (MapInfo[i].name != NULL) Bfree(MapInfo[i].name);
|
||||
if (MapInfo[i].filename != NULL) Bfree(MapInfo[i].filename);
|
||||
if (MapInfo[i].musicfn != NULL) Bfree(MapInfo[i].musicfn);
|
||||
Bfree(MapInfo[i].name);
|
||||
Bfree(MapInfo[i].filename);
|
||||
Bfree(MapInfo[i].musicfn);
|
||||
|
||||
G_FreeMapState(i);
|
||||
}
|
||||
|
||||
for (i=MAXQUOTES-1; i>=0; i--)
|
||||
{
|
||||
if (ScriptQuotes[i] != NULL) Bfree(ScriptQuotes[i]);
|
||||
if (ScriptQuoteRedefinitions[i] != NULL) Bfree(ScriptQuoteRedefinitions[i]);
|
||||
Bfree(ScriptQuotes[i]);
|
||||
Bfree(ScriptQuoteRedefinitions[i]);
|
||||
}
|
||||
|
||||
for (i=MAXPLAYERS-1; i>=0; i--)
|
||||
{
|
||||
if (g_player[i].ps != NULL) Bfree(g_player[i].ps);
|
||||
if (g_player[i].sync != NULL) Bfree(g_player[i].sync);
|
||||
Bfree(g_player[i].ps);
|
||||
Bfree(g_player[i].sync);
|
||||
}
|
||||
|
||||
for (i=MAXSOUNDS-1; i>=0; i--)
|
||||
{
|
||||
if (g_sounds[i].filename != NULL) Bfree(g_sounds[i].filename);
|
||||
Bfree(g_sounds[i].filename);
|
||||
}
|
||||
#if !defined LUNATIC
|
||||
if (label != NULL && label != (char *)&sprite[0]) Bfree(label);
|
||||
if (labelcode != NULL && labelcode != (int32_t *)§or[0]) Bfree(labelcode);
|
||||
if (script != NULL) Bfree(script);
|
||||
if (bitptr != NULL) Bfree(bitptr);
|
||||
if (label != (char *)&sprite[0]) Bfree(label);
|
||||
if (labelcode != (int32_t *)§or[0]) Bfree(labelcode);
|
||||
Bfree(script);
|
||||
Bfree(bitptr);
|
||||
|
||||
// if (MusicPtr != NULL) Bfree(MusicPtr);
|
||||
// Bfree(MusicPtr);
|
||||
|
||||
hash_free(&h_gamevars);
|
||||
hash_free(&h_arrays);
|
||||
|
@ -11702,8 +11702,8 @@ int32_t app_main(int32_t argc, const char **argv)
|
|||
|
||||
for (i=0; i < g_defModulesNum; ++i)
|
||||
Bfree(g_defModules[i]);
|
||||
Bfree(g_defModules);
|
||||
g_defModules = NULL;
|
||||
DO_FREE_AND_NULL(g_defModules);
|
||||
g_defModulesNum = 0;
|
||||
|
||||
if (E_PostInit())
|
||||
G_FatalEngineError();
|
||||
|
@ -11795,9 +11795,9 @@ int32_t app_main(int32_t argc, const char **argv)
|
|||
initprintf("There was an error loading the sprite clipping map (status %d).\n", i);
|
||||
|
||||
for (i=0; i < g_clipMapFilesNum; ++i)
|
||||
Bfree (g_clipMapFiles[i]);
|
||||
Bfree (g_clipMapFiles);
|
||||
g_clipMapFiles = NULL;
|
||||
Bfree(g_clipMapFiles[i]);
|
||||
DO_FREE_AND_NULL(g_clipMapFiles);
|
||||
g_clipMapFilesNum = 0;
|
||||
#endif
|
||||
|
||||
// check if the minifont will support lowercase letters (3136-3161)
|
||||
|
|
|
@ -2425,14 +2425,8 @@ void C_UndefineLevel(int32_t vol, int32_t lev)
|
|||
{
|
||||
map_t *const map = &MapInfo[(MAXLEVELS*vol)+lev];
|
||||
|
||||
if (map->filename)
|
||||
Bfree(map->filename);
|
||||
map->filename = NULL;
|
||||
|
||||
if (map->name)
|
||||
Bfree(map->name);
|
||||
map->name = NULL;
|
||||
|
||||
DO_FREE_AND_NULL(map->filename);
|
||||
DO_FREE_AND_NULL(map->name);
|
||||
map->partime = 0;
|
||||
map->designertime = 0;
|
||||
}
|
||||
|
@ -2460,8 +2454,8 @@ void C_AllocProjectile(int32_t j)
|
|||
|
||||
void C_FreeProjectile(int32_t j)
|
||||
{
|
||||
Bfree(g_tile[j].proj);
|
||||
g_tile[j].proj = g_tile[j].defproj = NULL;
|
||||
DO_FREE_AND_NULL(g_tile[j].proj);
|
||||
g_tile[j].defproj = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -6601,8 +6595,7 @@ void C_Compile(const char *filenam)
|
|||
kread(fp,(char *)textptr,fs);
|
||||
kclose(fp);
|
||||
|
||||
if (script != NULL)
|
||||
Bfree(script);
|
||||
Bfree(script);
|
||||
|
||||
script = (intptr_t *)Xcalloc(1,g_scriptSize * sizeof(intptr_t));
|
||||
bitptr = (char *)Xcalloc(1,(((g_scriptSize+7)>>3)+1) * sizeof(uint8_t));
|
||||
|
@ -6626,8 +6619,7 @@ void C_Compile(const char *filenam)
|
|||
C_Include(g_scriptModules[i]);
|
||||
Bfree(g_scriptModules[i]);
|
||||
}
|
||||
Bfree(g_scriptModules);
|
||||
g_scriptModules = NULL;
|
||||
DO_FREE_AND_NULL(g_scriptModules);
|
||||
g_scriptModulesNum = 0;
|
||||
|
||||
flushlogwindow = 1;
|
||||
|
@ -6637,8 +6629,7 @@ void C_Compile(const char *filenam)
|
|||
|
||||
//*script = (intptr_t) g_scriptPtr;
|
||||
|
||||
Bfree(mptr);
|
||||
mptr = NULL;
|
||||
DO_FREE_AND_NULL(mptr);
|
||||
|
||||
if (g_numCompilerWarnings|g_numCompilerErrors)
|
||||
initprintf("Found %d warning(s), %d error(s).\n",g_numCompilerWarnings,g_numCompilerErrors);
|
||||
|
|
|
@ -232,12 +232,8 @@ static void FreeGameList(void)
|
|||
while (listgrps)
|
||||
{
|
||||
Bfree(listgrps->name);
|
||||
|
||||
if (listgrps->scriptname)
|
||||
Bfree(listgrps->scriptname);
|
||||
|
||||
if (listgrps->defname)
|
||||
Bfree(listgrps->defname);
|
||||
Bfree(listgrps->scriptname);
|
||||
Bfree(listgrps->defname);
|
||||
|
||||
grpinfo_t * const fg = listgrps->next;
|
||||
Bfree(listgrps);
|
||||
|
|
|
@ -212,11 +212,7 @@ void SDLDrv_PCM_Shutdown(void)
|
|||
DummyChunk = NULL;
|
||||
}
|
||||
|
||||
if (DummyBuffer != NULL)
|
||||
{
|
||||
free(DummyBuffer);
|
||||
DummyBuffer = NULL;
|
||||
}
|
||||
DO_FREE_AND_NULL(DummyBuffer);
|
||||
|
||||
Mix_CloseAudio();
|
||||
|
||||
|
|
|
@ -658,8 +658,7 @@ void MV_ReleaseFLACVoice(VoiceNode *voice)
|
|||
FLAC__stream_decoder_finish(fd->stream);
|
||||
FLAC__stream_decoder_delete(fd->stream);
|
||||
}
|
||||
if (fd->block != NULL)
|
||||
free(fd->block);
|
||||
free(fd->block);
|
||||
free(fd);
|
||||
|
||||
voice->rawdataptr = 0;
|
||||
|
|
|
@ -521,8 +521,7 @@ void MV_ReleaseXAVoice( VoiceNode * voice )
|
|||
return;
|
||||
}
|
||||
|
||||
if (xad->block != NULL)
|
||||
free(xad->block);
|
||||
free(xad->block);
|
||||
free(xad);
|
||||
|
||||
voice->rawdataptr = 0;
|
||||
|
|
|
@ -316,8 +316,7 @@ int32_t ANIM_LoadAnim(const uint8_t *buffer, int32_t length)
|
|||
|
||||
void ANIM_FreeAnim(void)
|
||||
{
|
||||
Bfree(anim);
|
||||
anim = NULL;
|
||||
DO_FREE_AND_NULL(anim);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ int32_t SafeOpen(const char *filename, int32_t mode, int32_t sharemode)
|
|||
|
||||
if (h < MaxFiles)
|
||||
{
|
||||
if (FileNames[h]) Bfree(FileNames[h]);
|
||||
Bfree(FileNames[h]);
|
||||
FileNames[h] = (char*)Xmalloc(strlen(filename)+1);
|
||||
strcpy(FileNames[h], filename);
|
||||
}
|
||||
|
@ -105,8 +105,7 @@ void SafeClose(int32_t handle)
|
|||
|
||||
if (handle < MaxFiles && FileNames[handle])
|
||||
{
|
||||
Bfree(FileNames[handle]);
|
||||
FileNames[handle] = NULL;
|
||||
DO_FREE_AND_NULL(FileNames[handle]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -101,20 +101,14 @@ void SCRIPT_FreeSection(ScriptSectionType * section)
|
|||
{
|
||||
e = section->entries->nextentry;
|
||||
|
||||
if (section->entries->name)
|
||||
Bfree(section->entries->name);
|
||||
if (section->entries->value)
|
||||
Bfree(section->entries->value);
|
||||
|
||||
Bfree(section->entries->name);
|
||||
Bfree(section->entries->value);
|
||||
Bfree(section->entries);
|
||||
section->entries = e;
|
||||
}
|
||||
|
||||
if (section->entries->name)
|
||||
Bfree(section->entries->name);
|
||||
if (section->entries->value)
|
||||
Bfree(section->entries->value);
|
||||
|
||||
Bfree(section->entries->name);
|
||||
Bfree(section->entries->value);
|
||||
Bfree(section->entries);
|
||||
Bfree(section->name);
|
||||
}
|
||||
|
@ -227,7 +221,7 @@ void SCRIPT_AddEntry(int32_t scripthandle, const char * sectionname, const char
|
|||
}
|
||||
}
|
||||
|
||||
if (e->value) Bfree(e->value);
|
||||
Bfree(e->value);
|
||||
e->value = Bstrdup(entryvalue);
|
||||
}
|
||||
|
||||
|
|
|
@ -284,10 +284,7 @@ void El_ClearErrors(void)
|
|||
{
|
||||
int32_t i;
|
||||
for (i=0; i<EL_MAXERRORS; i++)
|
||||
{
|
||||
Bfree(el_errorMsgs[i]);
|
||||
el_errorMsgs[i] = NULL;
|
||||
}
|
||||
DO_FREE_AND_NULL(el_errorMsgs[i]);
|
||||
el_numErrors = el_tooMuchErrors = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -130,11 +130,7 @@ void taglab_init()
|
|||
hash_init(&g_taglab.hashtab);
|
||||
|
||||
for (i=0; i<32768; i++)
|
||||
{
|
||||
if (g_taglab.label[i])
|
||||
Bfree(g_taglab.label[i]);
|
||||
g_taglab.label[i] = NULL;
|
||||
}
|
||||
DO_FREE_AND_NULL(g_taglab.label[i]);
|
||||
}
|
||||
|
||||
int32_t taglab_load(const char *filename, int32_t flags)
|
||||
|
@ -286,8 +282,7 @@ int32_t taglab_add(const char *label, int16_t tag)
|
|||
// hash_delete(&g_taglab.hashtab, g_taglab.label[tag]);
|
||||
|
||||
// a label having the same tag number as 'tag' is deleted
|
||||
Bfree(g_taglab.label[tag]);
|
||||
g_taglab.label[tag] = NULL;
|
||||
DO_FREE_AND_NULL(g_taglab.label[tag]);
|
||||
diddel |= 1;
|
||||
}
|
||||
else
|
||||
|
@ -299,8 +294,7 @@ int32_t taglab_add(const char *label, int16_t tag)
|
|||
if (olabeltag>=0)
|
||||
{
|
||||
// the label gets assigned to a new tag number ('tag deleted')
|
||||
Bfree(g_taglab.label[olabeltag]);
|
||||
g_taglab.label[olabeltag] = NULL;
|
||||
DO_FREE_AND_NULL(g_taglab.label[olabeltag]);
|
||||
diddel |= 2;
|
||||
}
|
||||
}
|
||||
|
@ -1432,10 +1426,7 @@ static void M_Clear(StatusBarMenu *m)
|
|||
Bmemset(m->name, 0, sizeof(m->name));
|
||||
|
||||
for (i=0; i<MENU_MAX_ENTRIES; i++)
|
||||
{
|
||||
Bfree(m->description[i]);
|
||||
m->description[i] = NULL;
|
||||
}
|
||||
DO_FREE_AND_NULL(m->description[i]);
|
||||
}
|
||||
|
||||
static int32_t M_HaveDescription(StatusBarMenu *m)
|
||||
|
|
|
@ -1810,9 +1810,7 @@ static int32_t C_ParseCommand(void)
|
|||
statesinfo[j].numlocals = 0;
|
||||
Bsprintf(g_szCurrentBlockName, "%s", statesinfo[j].name);
|
||||
|
||||
if (cs.curStateMenuName)
|
||||
Bfree(cs.curStateMenuName);
|
||||
cs.curStateMenuName = NULL;
|
||||
DO_FREE_AND_NULL(cs.curStateMenuName);
|
||||
|
||||
if (C_GetKeyword() < 0)
|
||||
{
|
||||
|
@ -1953,8 +1951,7 @@ static int32_t C_ParseCommand(void)
|
|||
if (cs.curStateMenuName)
|
||||
{
|
||||
registerMenuFunction(cs.curStateMenuName, j);
|
||||
Bfree(cs.curStateMenuName);
|
||||
cs.curStateMenuName = NULL;
|
||||
DO_FREE_AND_NULL(cs.curStateMenuName);
|
||||
}
|
||||
|
||||
g_didDefineSomething = 1;
|
||||
|
@ -3753,8 +3750,7 @@ void C_Compile(const char *filenameortext, int32_t isfilename)
|
|||
|
||||
//*script = g_scriptPtr-script;
|
||||
|
||||
if (mptr)
|
||||
Bfree(mptr);
|
||||
Bfree(mptr);
|
||||
|
||||
if (g_stateCount > ostateCount)
|
||||
{
|
||||
|
|
|
@ -42,11 +42,8 @@ static void Gv_Clear(void)
|
|||
{
|
||||
DO_FREE_AND_NULL(aGameVars[i].szLabel);
|
||||
|
||||
if ((aGameVars[i].dwFlags & GAMEVAR_USER_MASK) && aGameVars[i].val.plValues)
|
||||
{
|
||||
Bfree(aGameVars[i].val.plValues);
|
||||
aGameVars[i].val.plValues = NULL;
|
||||
}
|
||||
if (aGameVars[i].dwFlags & GAMEVAR_USER_MASK)
|
||||
DO_FREE_AND_NULL(aGameVars[i].val.plValues);
|
||||
|
||||
aGameVars[i].val.lValue = 0;
|
||||
aGameVars[i].dwFlags |= GAMEVAR_RESET;
|
||||
|
@ -58,11 +55,8 @@ static void Gv_Clear(void)
|
|||
|
||||
DO_FREE_AND_NULL(gar->szLabel);
|
||||
|
||||
if ((gar->dwFlags & GAMEARRAY_NORMAL) && gar->vals)
|
||||
{
|
||||
Bfree(gar->vals);
|
||||
gar->vals = NULL;
|
||||
}
|
||||
if (gar->dwFlags & GAMEARRAY_NORMAL)
|
||||
DO_FREE_AND_NULL(gar->vals);
|
||||
|
||||
gar->dwFlags |= GAMEARRAY_RESET;
|
||||
}
|
||||
|
@ -194,9 +188,7 @@ int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags)
|
|||
if (aGameVars[i].dwFlags & GAMEVAR_USER_MASK)
|
||||
{
|
||||
// only free if not system
|
||||
if (aGameVars[i].val.plValues)
|
||||
Bfree(aGameVars[i].val.plValues);
|
||||
aGameVars[i].val.plValues = NULL;
|
||||
DO_FREE_AND_NULL(aGameVars[i].val.plValues);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1163,9 +1163,8 @@ void MIDI_StopSong
|
|||
_MIDI_Funcs->ReleasePatches();
|
||||
}
|
||||
|
||||
Bfree(_MIDI_TrackPtr);
|
||||
DO_FREE_AND_NULL(_MIDI_TrackPtr);
|
||||
|
||||
_MIDI_TrackPtr = NULL;
|
||||
_MIDI_NumTracks = 0;
|
||||
_MIDI_TrackMemSize = 0;
|
||||
|
||||
|
@ -1252,9 +1251,8 @@ int32_t MIDI_PlaySong
|
|||
{
|
||||
if (B_UNBUF32(ptr) != MIDI_TRACK_SIGNATURE)
|
||||
{
|
||||
Bfree(_MIDI_TrackPtr);
|
||||
DO_FREE_AND_NULL(_MIDI_TrackPtr);
|
||||
|
||||
_MIDI_TrackPtr = NULL;
|
||||
_MIDI_TrackMemSize = 0;
|
||||
|
||||
return(MIDI_InvalidTrack);
|
||||
|
|
|
@ -1454,11 +1454,7 @@ end_vol4a:
|
|||
Gv_ResetSystemDefaults();
|
||||
|
||||
for (i=0; i<(MAXVOLUMES*MAXLEVELS); i++)
|
||||
if (MapInfo[i].savedstate)
|
||||
{
|
||||
Baligned_free(MapInfo[i].savedstate);
|
||||
MapInfo[i].savedstate = NULL;
|
||||
}
|
||||
ALIGNED_FREE_AND_NULL(MapInfo[i].savedstate);
|
||||
|
||||
if (ud.m_coop != 1)
|
||||
{
|
||||
|
@ -2058,10 +2054,7 @@ void G_FreeMapState(int32_t mapnum)
|
|||
{
|
||||
if (aGameVars[j].dwFlags & GAMEVAR_NORESET) continue;
|
||||
if (aGameVars[j].dwFlags & (GAMEVAR_PERPLAYER|GAMEVAR_PERACTOR))
|
||||
{
|
||||
if (mapinfo->savedstate->vars[j])
|
||||
Baligned_free(mapinfo->savedstate->vars[j]);
|
||||
}
|
||||
Baligned_free(mapinfo->savedstate->vars[j]);
|
||||
}
|
||||
#else
|
||||
Bfree(mapinfo->savedstate->savecode);
|
||||
|
|
|
@ -1647,8 +1647,7 @@ static void sv_prescriptsave_once()
|
|||
}
|
||||
static void sv_prescriptload_once()
|
||||
{
|
||||
if (script)
|
||||
Bfree(script);
|
||||
Bfree(script);
|
||||
script = (intptr_t *)Xmalloc(g_scriptSize * sizeof(script[0]));
|
||||
}
|
||||
static void sv_postscript_once()
|
||||
|
|
|
@ -788,7 +788,7 @@ int32_t startwin_run(void)
|
|||
for (e=wavedevs->devs; e; e=d)
|
||||
{
|
||||
d = e->next;
|
||||
if (e->devs) Bfree(e->devs);
|
||||
Bfree(e->devs);
|
||||
Bfree(e);
|
||||
}
|
||||
Bfree(wavedevs);
|
||||
|
|
|
@ -11,8 +11,7 @@ char *g_grpNamePtr = NULL;
|
|||
|
||||
void clearGrpNamePtr(void)
|
||||
{
|
||||
if (g_grpNamePtr != NULL)
|
||||
Bfree(g_grpNamePtr);
|
||||
Bfree(g_grpNamePtr);
|
||||
// g_grpNamePtr assumed to be assigned to right after
|
||||
}
|
||||
|
||||
|
|
|
@ -1034,8 +1034,8 @@ InitGame(int32_t argc, const char **argv)
|
|||
|
||||
for (i=0; i < g_defModulesNum; ++i)
|
||||
Bfree(g_defModules[i]);
|
||||
Bfree(g_defModules);
|
||||
g_defModules = NULL;
|
||||
DO_FREE_AND_NULL(g_defModules);
|
||||
g_defModulesNum = 0;
|
||||
|
||||
if (E_PostInit())
|
||||
SW_FatalEngineError();
|
||||
|
|
|
@ -628,7 +628,7 @@ void LoadCustomInfoFromScript(char *filename)
|
|||
char *t;
|
||||
if (scriptfile_getstring(script, &t)) break;
|
||||
|
||||
if (custommaps[curmap].LevelName) free(custommaps[curmap].LevelName);
|
||||
Bfree(custommaps[curmap].LevelName);
|
||||
custommaps[curmap].LevelName = strdup(t);
|
||||
LevelInfo[curmap].LevelName = custommaps[curmap].LevelName;
|
||||
break;
|
||||
|
@ -638,7 +638,7 @@ void LoadCustomInfoFromScript(char *filename)
|
|||
char *t;
|
||||
if (scriptfile_getstring(script, &t)) break;
|
||||
|
||||
if (custommaps[curmap].SongName) free(custommaps[curmap].SongName);
|
||||
Bfree(custommaps[curmap].SongName);
|
||||
custommaps[curmap].SongName = strdup(t);
|
||||
LevelInfo[curmap].SongName = custommaps[curmap].SongName;
|
||||
break;
|
||||
|
@ -648,7 +648,7 @@ void LoadCustomInfoFromScript(char *filename)
|
|||
char *t;
|
||||
if (scriptfile_getstring(script, &t)) break;
|
||||
|
||||
if (custommaps[curmap].Description) free(custommaps[curmap].Description);
|
||||
Bfree(custommaps[curmap].Description);
|
||||
custommaps[curmap].Description = strdup(t);
|
||||
LevelInfo[curmap].Description = custommaps[curmap].Description;
|
||||
break;
|
||||
|
@ -660,7 +660,7 @@ void LoadCustomInfoFromScript(char *filename)
|
|||
if (scriptfile_getnumber(script, &n)) break;
|
||||
|
||||
Bsnprintf(s, 10, "%d : %02d", n/60, n%60);
|
||||
if (custommaps[curmap].BestTime) free(custommaps[curmap].BestTime);
|
||||
Bfree(custommaps[curmap].BestTime);
|
||||
custommaps[curmap].BestTime = strdup(s);
|
||||
LevelInfo[curmap].BestTime = custommaps[curmap].BestTime;
|
||||
break;
|
||||
|
@ -672,7 +672,7 @@ void LoadCustomInfoFromScript(char *filename)
|
|||
if (scriptfile_getnumber(script, &n)) break;
|
||||
|
||||
Bsnprintf(s, 10, "%d : %02d", n/60, n%60);
|
||||
if (custommaps[curmap].ParTime) free(custommaps[curmap].ParTime);
|
||||
Bfree(custommaps[curmap].ParTime);
|
||||
custommaps[curmap].ParTime = strdup(s);
|
||||
LevelInfo[curmap].ParTime = custommaps[curmap].ParTime;
|
||||
break;
|
||||
|
@ -882,7 +882,7 @@ void LoadCustomInfoFromScript(char *filename)
|
|||
|
||||
if (name)
|
||||
{
|
||||
if (custominventoryname[in]) free(custominventoryname[in]);
|
||||
Bfree(custominventoryname[in]);
|
||||
custominventoryname[in] = strdup(name);
|
||||
InventoryDecls[in].name = custominventoryname[in];
|
||||
}
|
||||
|
@ -956,7 +956,7 @@ void LoadCustomInfoFromScript(char *filename)
|
|||
if (maxammo >= 0) DamageData[id].max_ammo = maxammo;
|
||||
if (name)
|
||||
{
|
||||
if (customweaponname[0][id]) free(customweaponname[0][id]);
|
||||
Bfree(customweaponname[0][id]);
|
||||
customweaponname[0][id] = strdup(name);
|
||||
DamageData[id].weapon_name = customweaponname[0][id];
|
||||
}
|
||||
|
@ -966,7 +966,7 @@ void LoadCustomInfoFromScript(char *filename)
|
|||
{
|
||||
if (ammo)
|
||||
{
|
||||
if (customweaponname[1][id]) free(customweaponname[1][id]);
|
||||
Bfree(customweaponname[1][id]);
|
||||
customweaponname[1][id] = strdup(ammo);
|
||||
DamageData[id].ammo_name = customweaponname[1][id];
|
||||
}
|
||||
|
|
|
@ -543,11 +543,7 @@ StopSong(void)
|
|||
}
|
||||
SongType = SongTypeNone;
|
||||
|
||||
if (SongName)
|
||||
{
|
||||
free(SongName);
|
||||
}
|
||||
SongName = 0;
|
||||
DO_FREE_AND_NULL(SongName);
|
||||
SongTrack = 0;
|
||||
|
||||
if (SongPtr)
|
||||
|
|
Loading…
Reference in a new issue