mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-07 07:21:10 +00:00
Clear up after r2495. (Because I'm a pedantic asshole.)
- in Mapster, pre-form the default 10 clip map names before returning from G_CheckCommandLine() so it gets loaded even if we passed no cmdline args. - malloc + strlen + strcpy --> strdup - don't need to spank dead variables ;) - we may call calloc with zero size, which isn't bad by itself, but asserting for non-null afterwards is. Allocs of 0 are implementation-defined, and may well return a null pointer (C99 7.20.3). git-svn-id: https://svn.eduke32.com/eduke32@2502 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
9628041766
commit
97020caf73
3 changed files with 34 additions and 56 deletions
|
@ -1285,10 +1285,10 @@ int32_t clipmapinfo_load(void)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_clipMapFilesNum)
|
||||||
fisec = (int32_t *) Bcalloc(g_clipMapFilesNum, sizeof (int32_t));
|
fisec = (int32_t *) Bcalloc(g_clipMapFilesNum, sizeof (int32_t));
|
||||||
assert(fisec);
|
if (g_clipMapFilesNum)
|
||||||
fispr = (int32_t *) Bcalloc(g_clipMapFilesNum, sizeof (int32_t));
|
fispr = (int32_t *) Bcalloc(g_clipMapFilesNum, sizeof (int32_t));
|
||||||
assert(fispr);
|
|
||||||
|
|
||||||
quickloadboard = 1;
|
quickloadboard = 1;
|
||||||
for (fi = 0; fi < g_clipMapFilesNum; ++fi)
|
for (fi = 0; fi < g_clipMapFilesNum; ++fi)
|
||||||
|
@ -1341,10 +1341,8 @@ int32_t clipmapinfo_load(void)
|
||||||
{
|
{
|
||||||
clipmapinfo_init();
|
clipmapinfo_init();
|
||||||
|
|
||||||
free(fisec);
|
Bfree(fisec);
|
||||||
fisec = NULL;
|
Bfree(fispr);
|
||||||
free(fispr);
|
|
||||||
fispr = NULL;
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1366,10 +1364,8 @@ int32_t clipmapinfo_load(void)
|
||||||
{
|
{
|
||||||
clipmapinfo_init();
|
clipmapinfo_init();
|
||||||
|
|
||||||
free(fisec);
|
Bfree(fisec);
|
||||||
fisec = NULL;
|
Bfree(fispr);
|
||||||
free(fispr);
|
|
||||||
fispr = NULL;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1411,10 +1407,8 @@ int32_t clipmapinfo_load(void)
|
||||||
{
|
{
|
||||||
clipmapinfo_init();
|
clipmapinfo_init();
|
||||||
|
|
||||||
free(fisec);
|
Bfree(fisec);
|
||||||
fisec = NULL;
|
Bfree(fispr);
|
||||||
free(fispr);
|
|
||||||
fispr = NULL;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1449,10 +1443,8 @@ int32_t clipmapinfo_load(void)
|
||||||
clipinfo[sectoidx[k]].picnum);
|
clipinfo[sectoidx[k]].picnum);
|
||||||
clipmapinfo_init();
|
clipmapinfo_init();
|
||||||
|
|
||||||
free(fisec);
|
Bfree(fisec);
|
||||||
fisec = NULL;
|
Bfree(fispr);
|
||||||
free(fispr);
|
|
||||||
fispr = NULL;
|
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
@ -1515,10 +1507,8 @@ int32_t clipmapinfo_load(void)
|
||||||
" for sprite %d.\n", g_clipMapFiles[fi], outersect-fisec[fi], ns-fisec[fi], i-fispr[fi]);
|
" for sprite %d.\n", g_clipMapFiles[fi], outersect-fisec[fi], ns-fisec[fi], i-fispr[fi]);
|
||||||
clipmapinfo_init();
|
clipmapinfo_init();
|
||||||
|
|
||||||
free(fisec);
|
Bfree(fisec);
|
||||||
fisec = NULL;
|
Bfree(fispr);
|
||||||
free(fispr);
|
|
||||||
fispr = NULL;
|
|
||||||
|
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
@ -1536,10 +1526,8 @@ int32_t clipmapinfo_load(void)
|
||||||
g_clipMapFiles[fi], ns-fisec[fi], sectoidx[ns], i-fispr[fi], numclipmaps);
|
g_clipMapFiles[fi], ns-fisec[fi], sectoidx[ns], i-fispr[fi], numclipmaps);
|
||||||
clipmapinfo_init();
|
clipmapinfo_init();
|
||||||
|
|
||||||
free(fisec);
|
Bfree(fisec);
|
||||||
fisec = NULL;
|
Bfree(fispr);
|
||||||
free(fispr);
|
|
||||||
fispr = NULL;
|
|
||||||
|
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
@ -1553,10 +1541,8 @@ int32_t clipmapinfo_load(void)
|
||||||
initprintf("clip map: INTERNAL ERROR: outersect==-1!\n");
|
initprintf("clip map: INTERNAL ERROR: outersect==-1!\n");
|
||||||
clipmapinfo_init();
|
clipmapinfo_init();
|
||||||
|
|
||||||
free(fisec);
|
Bfree(fisec);
|
||||||
fisec = NULL;
|
Bfree(fispr);
|
||||||
free(fispr);
|
|
||||||
fispr = NULL;
|
|
||||||
|
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
@ -1660,10 +1646,8 @@ int32_t clipmapinfo_load(void)
|
||||||
{
|
{
|
||||||
clipmapinfo_init();
|
clipmapinfo_init();
|
||||||
|
|
||||||
free(fisec);
|
Bfree(fisec);
|
||||||
fisec = NULL;
|
Bfree(fispr);
|
||||||
free(fispr);
|
|
||||||
fispr = NULL;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1732,10 +1716,8 @@ int32_t clipmapinfo_load(void)
|
||||||
if (lwcp > 0)
|
if (lwcp > 0)
|
||||||
initprintf("Loaded clip map%s.\n", lwcp==1?"":"s");
|
initprintf("Loaded clip map%s.\n", lwcp==1?"":"s");
|
||||||
|
|
||||||
free(fisec);
|
Bfree(fisec);
|
||||||
fisec = NULL;
|
Bfree(fispr);
|
||||||
free(fispr);
|
|
||||||
fispr = NULL;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8448,6 +8448,15 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
|
||||||
|
|
||||||
mapster32_fullpath = argv[0];
|
mapster32_fullpath = argv[0];
|
||||||
|
|
||||||
|
// pre-form the default 10 clipmaps
|
||||||
|
for (j = '0'; j<='9'; ++j)
|
||||||
|
{
|
||||||
|
clipshape[10] = j;
|
||||||
|
g_clipMapFiles = (char **) Brealloc (g_clipMapFiles, (g_clipMapFilesNum+1) * sizeof(char *));
|
||||||
|
g_clipMapFiles[g_clipMapFilesNum] = Bstrdup(clipshape);
|
||||||
|
++g_clipMapFilesNum;
|
||||||
|
}
|
||||||
|
|
||||||
if (argc <= 1)
|
if (argc <= 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -8461,16 +8470,6 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
|
||||||
testplay_addparam = Bmalloc(maxlen+argc);
|
testplay_addparam = Bmalloc(maxlen+argc);
|
||||||
testplay_addparam[0] = 0;
|
testplay_addparam[0] = 0;
|
||||||
|
|
||||||
// pre-form the default 10 clipmaps
|
|
||||||
for (j = '0'; j<='9'; ++j)
|
|
||||||
{
|
|
||||||
clipshape[10] = j;
|
|
||||||
g_clipMapFiles = (char **) Brealloc (g_clipMapFiles, (g_clipMapFilesNum+1) * sizeof(char *));
|
|
||||||
g_clipMapFiles[g_clipMapFilesNum] = Bmalloc(Bstrlen(clipshape) + 1);
|
|
||||||
Bstrcpy(g_clipMapFiles[g_clipMapFilesNum], clipshape);
|
|
||||||
++g_clipMapFilesNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
while (i < argc)
|
while (i < argc)
|
||||||
|
@ -8610,8 +8609,7 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
|
||||||
if (argc > i+1)
|
if (argc > i+1)
|
||||||
{
|
{
|
||||||
g_clipMapFiles = (char **) Brealloc (g_clipMapFiles, (g_clipMapFilesNum+1) * sizeof(char *));
|
g_clipMapFiles = (char **) Brealloc (g_clipMapFiles, (g_clipMapFilesNum+1) * sizeof(char *));
|
||||||
g_clipMapFiles[g_clipMapFilesNum] = Bmalloc(Bstrlen((char *)argv[i+1]) + 1);
|
g_clipMapFiles[g_clipMapFilesNum] = Bstrdup(argv[i+1]);
|
||||||
Bstrcpy(g_clipMapFiles[g_clipMapFilesNum], (char *)argv[i+1]);
|
|
||||||
++g_clipMapFilesNum;
|
++g_clipMapFilesNum;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8614,8 +8614,7 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
|
||||||
{
|
{
|
||||||
clipshape[10] = j;
|
clipshape[10] = j;
|
||||||
g_clipMapFiles = (char **) Brealloc (g_clipMapFiles, (g_clipMapFilesNum+1) * sizeof(char *));
|
g_clipMapFiles = (char **) Brealloc (g_clipMapFiles, (g_clipMapFilesNum+1) * sizeof(char *));
|
||||||
g_clipMapFiles[g_clipMapFilesNum] = Bmalloc(Bstrlen(clipshape) + 1);
|
g_clipMapFiles[g_clipMapFilesNum] = Bstrdup(clipshape);
|
||||||
Bstrcpy(g_clipMapFiles[g_clipMapFilesNum], clipshape);
|
|
||||||
++g_clipMapFilesNum;
|
++g_clipMapFilesNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8853,8 +8852,7 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
|
||||||
if (argc > i+1)
|
if (argc > i+1)
|
||||||
{
|
{
|
||||||
g_clipMapFiles = (char **) Brealloc (g_clipMapFiles, (g_clipMapFilesNum+1) * sizeof(char *));
|
g_clipMapFiles = (char **) Brealloc (g_clipMapFiles, (g_clipMapFilesNum+1) * sizeof(char *));
|
||||||
g_clipMapFiles[g_clipMapFilesNum] = Bmalloc(Bstrlen((char *)argv[i+1]) + 1);
|
g_clipMapFiles[g_clipMapFilesNum] = Bstrdup(argv[i+1]);
|
||||||
Bstrcpy(g_clipMapFiles[g_clipMapFilesNum], (char *)argv[i+1]);
|
|
||||||
++g_clipMapFilesNum;
|
++g_clipMapFilesNum;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue