summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-08-19 17:50:37 +0200
committerwm4 <wm4@nowhere>2012-08-20 15:36:05 +0200
commit41d6ddf5fbd287ad5d5a7ba44a2dfb82db4461fd (patch)
tree7a327738e3a580718eee956c6592d90ab9042cec
parent6386b11324cb2c0cb150123038192e3b3859f229 (diff)
downloadmpv-41d6ddf5fbd287ad5d5a7ba44a2dfb82db4461fd.tar.bz2
mpv-41d6ddf5fbd287ad5d5a7ba44a2dfb82db4461fd.tar.xz
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.
-rw-r--r--mplayer.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/mplayer.c b/mplayer.c
index 963d505637..48758b2967 100644
--- a/mplayer.c
+++ b/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,