unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: david@tethera.net
To: notmuch@notmuchmail.org
Cc: David Bremner <bremner@debian.org>
Subject: [PATCH 5/7] CLI: add --leak-report top level option
Date: Sat, 19 Jan 2013 14:25:56 -0400	[thread overview]
Message-ID: <1358619958-21209-6-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1358619958-21209-1-git-send-email-david@tethera.net>

From: David Bremner <bremner@debian.org>

This roughly mimics the samba4 argument. The presence of the command
line argument overrides any value of NOTMUCH_TALLOC_REPORT in the
environment.
---
 man/man1/notmuch.1 |    8 ++++++++
 notmuch.c          |   18 +++++++-----------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/man/man1/notmuch.1 b/man/man1/notmuch.1
index 6bf9b2e..5c58c41 100644
--- a/man/man1/notmuch.1
+++ b/man/man1/notmuch.1
@@ -70,6 +70,14 @@ Print a synopsis of available commands and exit.
 Print the installed version of notmuch, and exit.
 .RE
 
+.RS 4
+.TP 4
+.BI \-\-leak-report= path
+
+Write a detailed report of all memory allocated via talloc to
+.I path
+.RE
+
 .SH COMMANDS
 
 
diff --git a/notmuch.c b/notmuch.c
index a674481..f8d4b35 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -250,11 +250,13 @@ main (int argc, char *argv[])
     command_t *command;
     unsigned int i;
     notmuch_bool_t print_help=FALSE, print_version=FALSE;
+    const char* leak_report=NULL;
     int opt_index;
 
     notmuch_opt_desc_t options[] = {
 	{ NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 },
 	{ NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 },
+	{ NOTMUCH_OPT_STRING, &leak_report, "leak-report", 'l', 0 },
 	{ 0, 0, 0, 0, 0 }
     };
 
@@ -290,21 +292,15 @@ main (int argc, char *argv[])
 
 	if (strcmp (argv[opt_index], command->name) == 0) {
 	    int ret;
-	    char *talloc_report;
 
 	    ret = (command->function)(local, argc - opt_index, argv + opt_index);
 
-	    /* in the future support for this environment variable may
-	     * be supplemented or replaced by command line arguments
-	     * --leak-report and/or --leak-report-full */
-
-	    talloc_report = getenv ("NOTMUCH_TALLOC_REPORT");
-
-	    /* this relies on the previous call to
-	     * talloc_enable_null_tracking */
+	    if (leak_report == NULL) {
+		leak_report = getenv ("NOTMUCH_TALLOC_REPORT");
+	    }
 
-	    if (talloc_report && strcmp (talloc_report, "") != 0) {
-		FILE *report = fopen (talloc_report, "w");
+	    if (leak_report && (strcmp (leak_report, "") != 0)) {
+		FILE *report = fopen (leak_report, "w");
 		talloc_report_full (NULL, report);
 	    }
 
-- 
1.7.10.4

  parent reply	other threads:[~2013-01-19 18:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-19 18:25 update top level argument handling david
2013-01-19 18:25 ` [PATCH 1/7] emacs: don't use deprecated "notmuch search-tags" command david
2013-01-19 18:25 ` [PATCH 2/7] CLI: remove alias machinery, and "part", "search-tags" commands david
2013-01-19 18:25 ` [PATCH 3/7] CLI: convert top level argument parsing to use command-line-arguments david
2013-01-19 18:25 ` [PATCH 4/7] man: document existing top level options david
2013-01-19 18:25 ` david [this message]
2013-01-20 21:55   ` [PATCH 5/7] CLI: add --leak-report top level option Jameson Graef Rollins
2013-01-20 22:55     ` Tomi Ollila
2013-01-19 18:25 ` [PATCH 6/7] man: document NOTMUCH_TALLOC_REPORT environment variable david
2013-01-19 18:25 ` [PATCH 7/7] CLI: add simple error handling for talloc logging david
2013-01-21 16:18 ` update top level argument handling Jani Nikula
2013-01-23  1:25   ` David Bremner
2013-01-23  1:57     ` Tomi Ollila

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1358619958-21209-6-git-send-email-david@tethera.net \
    --to=david@tethera.net \
    --cc=bremner@debian.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).