Add myargmalloc boolean to detect whether we allocated myargv ourselves or not, so we don't free myargv if we didn't
This commit is contained in:
parent
fe43deacec
commit
08af33c51f
|
@ -25,6 +25,10 @@ INT32 myargc;
|
||||||
*/
|
*/
|
||||||
char **myargv;
|
char **myargv;
|
||||||
|
|
||||||
|
/** \brief did we alloc myargv ourselves?
|
||||||
|
*/
|
||||||
|
boolean myargmalloc = false;
|
||||||
|
|
||||||
/** \brief founded the parm
|
/** \brief founded the parm
|
||||||
*/
|
*/
|
||||||
static INT32 found;
|
static INT32 found;
|
||||||
|
@ -176,6 +180,7 @@ void M_FindResponseFile(void)
|
||||||
free(file);
|
free(file);
|
||||||
I_Error("Not enough memory to read response file");
|
I_Error("Not enough memory to read response file");
|
||||||
}
|
}
|
||||||
|
myargmalloc = true; // mark as having been allocated by us
|
||||||
memset(myargv, 0, sizeof (char *) * MAXARGVS);
|
memset(myargv, 0, sizeof (char *) * MAXARGVS);
|
||||||
myargv[0] = firstargv;
|
myargv[0] = firstargv;
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
//
|
//
|
||||||
extern INT32 myargc;
|
extern INT32 myargc;
|
||||||
extern char **myargv;
|
extern char **myargv;
|
||||||
|
extern boolean myargmalloc;
|
||||||
|
|
||||||
// Returns the position of the given parameter in the arg list (0 if not found).
|
// Returns the position of the given parameter in the arg list (0 if not found).
|
||||||
INT32 M_CheckParm(const char *check);
|
INT32 M_CheckParm(const char *check);
|
||||||
|
|
|
@ -2139,7 +2139,8 @@ void I_Quit(void)
|
||||||
printf("\r");
|
printf("\r");
|
||||||
ShowEndTxt();
|
ShowEndTxt();
|
||||||
}
|
}
|
||||||
free(myargv); // Deallocate allocated memory
|
if (myargmalloc)
|
||||||
|
free(myargv); // Deallocate allocated memory
|
||||||
death:
|
death:
|
||||||
W_Shutdown();
|
W_Shutdown();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
|
@ -2301,7 +2301,8 @@ void I_Quit(void)
|
||||||
printf("\r");
|
printf("\r");
|
||||||
ShowEndTxt();
|
ShowEndTxt();
|
||||||
}
|
}
|
||||||
free(myargv); // Deallocate allocated memory
|
if (myargmalloc)
|
||||||
|
free(myargv); // Deallocate allocated memory
|
||||||
death:
|
death:
|
||||||
W_Shutdown();
|
W_Shutdown();
|
||||||
#ifdef GP2X
|
#ifdef GP2X
|
||||||
|
|
|
@ -771,7 +771,8 @@ void I_Quit(void)
|
||||||
ShowEndTxt(co);
|
ShowEndTxt(co);
|
||||||
}
|
}
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
free(myargv); // Deallocate allocated memory
|
if (myargmalloc)
|
||||||
|
free(myargv); // Deallocate allocated memory
|
||||||
W_Shutdown();
|
W_Shutdown();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue