--- /dev/null
+Return-Path: <amthrax@drake.mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 49BD9431FBC\r
+ for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 21:50:16 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id LvCPwZ4rrbdA for <notmuch@notmuchmail.org>;\r
+ Sat, 28 Jan 2012 21:50:15 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
+ [18.9.25.15])\r
+ by olra.theworths.org (Postfix) with ESMTP id 88925431FB6\r
+ for <notmuch@notmuchmail.org>; Sat, 28 Jan 2012 21:50:15 -0800 (PST)\r
+X-AuditID: 1209190f-b7f8a6d000000914-be-4f24de173f27\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+ by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id C4.B4.02324.71ED42F4; Sun, 29 Jan 2012 00:50:15 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q0T5oErF014841; \r
+ Sun, 29 Jan 2012 00:50:14 -0500\r
+Received: from drake.mit.edu\r
+ (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+ [209.6.116.242]) (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0T5oCbS028025\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Sun, 29 Jan 2012 00:50:13 -0500 (EST)\r
+Received: from amthrax by drake.mit.edu with local (Exim 4.77)\r
+ (envelope-from <amthrax@drake.mit.edu>)\r
+ id 1RrNeW-0007ag-C3; Sun, 29 Jan 2012 00:50:12 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/3] lib: Use talloc to simplify cleanup in\r
+ notmuch_database_open\r
+Date: Sun, 29 Jan 2012 00:50:10 -0500\r
+Message-Id: <1327816210-29124-3-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.7.3\r
+In-Reply-To: <1327816210-29124-1-git-send-email-amdragon@mit.edu>\r
+References: <1327816210-29124-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrMIsWRmVeSWpSXmKPExsUixCmqrSt+T8Xf4FYfi8X1mzOZHRg9nq26\r
+ xRzAGMVlk5Kak1mWWqRvl8CVcbv/G2NBI2/Fw4ZHjA2MzVxdjJwcEgImElOunGKFsMUkLtxb\r
+ z9bFyMUhJLCPUaJ72WNmCGcDo8T11VtZIJz7TBJbt89hhXDmA2Xu/mYC6WcT0JDYtn85I4gt\r
+ IiAtsfPubKAiDg5mATWJP10qIGFhgUCJQy+ngpWzCKhKHP38hxnE5hVwkPh65zYbxBkKEudW\r
+ n2MHsTkFHCX+rFrBAmILAdU0NE5nnsDIv4CRYRWjbEpulW5uYmZOcWqybnFyYl5eapGuiV5u\r
+ ZoleakrpJkZw2Ejy72D8dlDpEKMAB6MSD++JpSr+QqyJZcWVuYcYJTmYlER5F9wBCvEl5adU\r
+ ZiQWZ8QXleakFh9ilOBgVhLhdZwJlONNSaysSi3Kh0lJc7AoifOqab3zExJITyxJzU5NLUgt\r
+ gsnKcHAoSfDOugvUKFiUmp5akZaZU4KQZuLgBBnOAzTcA6SGt7ggMbc4Mx0if4pRUUqcdyZI\r
+ QgAkkVGaB9cLi+tXjOJArwjzdoNU8QBTAlz3K6DBTECDI64qggwuSURISTUweiWGeh98oWLF\r
+ sjLlSglHUpn23/OTWs71POCT92DOd777Y0HatEUGm/c0xbjcPbvFxMB8vfdkrU8Hbp87fGzv\r
+ rEciTsyXnv9euGdqqtmtaTqsxVmbtX/cfy/uMeXsMo740y9WGARev2wcs6051clzU+7Zsg+X\r
+ duauUM+P2G+5nu+l8uSDl7/lPldiKc5INNRiLipOBACjnKdrxgIAAA==\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 29 Jan 2012 05:50:16 -0000\r
+\r
+Previously, we manually "free"d various pointers in\r
+notmuch_database_open. Use a local talloc context instead to simplify\r
+cleanup and eliminate various NULL pointer initializations and\r
+conditionals.\r
+---\r
+ lib/database.cc | 14 +++++---------\r
+ 1 files changed, 5 insertions(+), 9 deletions(-)\r
+\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index 94022d7..c928d02 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -582,15 +582,15 @@ notmuch_database_t *\r
+ notmuch_database_open (const char *path,\r
+ notmuch_database_mode_t mode)\r
+ {\r
++ void *local = talloc_new (NULL);\r
+ notmuch_database_t *notmuch = NULL;\r
+- char *notmuch_path = NULL, *xapian_path = NULL;\r
++ char *notmuch_path, *xapian_path;\r
+ struct stat st;\r
+ int err;\r
+ unsigned int i, version;\r
+ static int initialized = 0;\r
+ \r
+- if (asprintf (¬much_path, "%s/%s", path, ".notmuch") == -1) {\r
+- notmuch_path = NULL;\r
++ if (! (notmuch_path = talloc_asprintf (local, "%s/%s", path, ".notmuch"))) {\r
+ fprintf (stderr, "Out of memory\n");\r
+ goto DONE;\r
+ }\r
+@@ -602,8 +602,7 @@ notmuch_database_open (const char *path,\r
+ goto DONE;\r
+ }\r
+ \r
+- if (asprintf (&xapian_path, "%s/%s", notmuch_path, "xapian") == -1) {\r
+- xapian_path = NULL;\r
++ if (! (xapian_path = talloc_asprintf (local, "%s/%s", notmuch_path, "xapian"))) {\r
+ fprintf (stderr, "Out of memory\n");\r
+ goto DONE;\r
+ }\r
+@@ -708,10 +707,7 @@ notmuch_database_open (const char *path,\r
+ }\r
+ \r
+ DONE:\r
+- if (notmuch_path)\r
+- free (notmuch_path);\r
+- if (xapian_path)\r
+- free (xapian_path);\r
++ talloc_free (local);\r
+ \r
+ return notmuch;\r
+ }\r
+-- \r
+1.7.7.3\r
+\r