mirror of https://github.com/mpv-player/mpv
mplayer: enable talloc leak report if special environment is variable set
The functionality enabled with the --leak-report option is very useful for debugging. Introduce a check for the MPLAYER_LEAK_REPORT environment variable, and enable talloc leak report if it's set to "1". The environment variable encourages enabling leak report permanently during development. It's also a bit harder to get wrong: if the --leak-report option is not the first option, it's silently ignored. You can't put this option into a config file either. Enabling this with --enable-debug in configure is not an option, because the leak report code doesn't seem to be thread-safe, and thus is a bit dangerous. Also, move the code to the very beginning to make sure leak report is enabled before any other talloc function is used. Otherwise, these allocations could be missed.
This commit is contained in:
parent
6386b11324
commit
41d6ddf5fb
11
mplayer.c
11
mplayer.c
|
@ -3861,6 +3861,13 @@ static void detach_ptw32(void)
|
|||
|
||||
static void osdep_preinit(int *p_argc, char ***p_argv)
|
||||
{
|
||||
char *enable_talloc = getenv("MPLAYER_LEAK_REPORT");
|
||||
if (*p_argc > 1 && (strcmp((*p_argv)[1], "-leak-report") == 0
|
||||
|| strcmp((*p_argv)[1], "--leak-report") == 0))
|
||||
enable_talloc = "1";
|
||||
if (enable_talloc && strcmp(enable_talloc, "1") == 0)
|
||||
talloc_enable_leak_report();
|
||||
|
||||
GetCpuCaps(&gCpuCaps);
|
||||
|
||||
#ifdef __MINGW32__
|
||||
|
@ -3900,10 +3907,6 @@ int main(int argc, char *argv[])
|
|||
argv++;
|
||||
}
|
||||
|
||||
if (argc > 0 && (!strcmp(argv[0], "-leak-report")
|
||||
|| !strcmp(argv[0], "--leak-report")))
|
||||
talloc_enable_leak_report();
|
||||
|
||||
struct MPContext *mpctx = talloc(NULL, MPContext);
|
||||
*mpctx = (struct MPContext){
|
||||
.osd_function = OSD_PLAY,
|
||||
|
|
Loading…
Reference in New Issue