]> git.cworth.org Git - notmuch/commitdiff
lib: write talloc report in notmuch_database_destroy
authorDavid Bremner <david@tethera.net>
Sat, 19 Jun 2021 00:59:43 +0000 (21:59 -0300)
committerDavid Bremner <david@tethera.net>
Fri, 25 Jun 2021 12:20:37 +0000 (09:20 -0300)
Since most memory allocation is (ultimately) in the talloc context
defined by a notmuch_database_t pointer, this gives a more complete
view of memory still allocated at program shutdown.

We also change the talloc report in notmuch.c to mode "a" to avoid
clobbering the newly reported log.

lib/database.cc
notmuch.c

index 96458f6ff104a18ba28d59929b7597cf284feeec..0052cb659e896841e8c54e1850864fcd0ef1e8ad 100644 (file)
@@ -733,6 +733,15 @@ notmuch_status_t
 notmuch_database_destroy (notmuch_database_t *notmuch)
 {
     notmuch_status_t status;
+    const char* talloc_report;
+
+    talloc_report = getenv ("NOTMUCH_TALLOC_REPORT");
+    if (talloc_report && strcmp (talloc_report, "") != 0) {
+       FILE *report = fopen (talloc_report, "a");
+       if (report) {
+           talloc_report_full (notmuch, report);
+       }
+    }
 
     status = notmuch_database_close (notmuch);
 
index d0a94fc2650993ae18bbd1ae6eae0109c3ca249b..1404b70c3c06a5d0c6ca24849ee8e98395814029 100644 (file)
--- a/notmuch.c
+++ b/notmuch.c
@@ -589,7 +589,7 @@ main (int argc, char *argv[])
         * talloc_enable_null_tracking
         */
 
-       FILE *report = fopen (talloc_report, "w");
+       FILE *report = fopen (talloc_report, "a");
        if (report) {
            talloc_report_full (NULL, report);
        } else {