--- /dev/null
+Return-Path: <jani@nikula.org>\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 0C196431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 6 Feb 2012 14:21:28 -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 aIHGFXBTVUFq for <notmuch@notmuchmail.org>;\r
+ Mon, 6 Feb 2012 14:21:27 -0800 (PST)\r
+Received: from mail-lpp01m010-f53.google.com (mail-lpp01m010-f53.google.com\r
+ [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 275BE431FAE\r
+ for <notmuch@notmuchmail.org>; Mon, 6 Feb 2012 14:21:27 -0800 (PST)\r
+Received: by lahd3 with SMTP id d3so3964852lah.26\r
+ for <notmuch@notmuchmail.org>; Mon, 06 Feb 2012 14:21:25 -0800 (PST)\r
+Received: by 10.152.146.163 with SMTP id td3mr109516lab.31.1328566885702;\r
+ Mon, 06 Feb 2012 14:21:25 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw4-fe50f800-253.dhcp.inet.fi.\r
+ [84.248.80.253])\r
+ by mx.google.com with ESMTPS id j4sm14067691lbf.6.2012.02.06.14.21.23\r
+ (version=SSLv3 cipher=OTHER); Mon, 06 Feb 2012 14:21:24 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Ethan Glasser-Camp <glasse@cs.rpi.edu>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] Free the results of scandir()\r
+In-Reply-To: <1328565769-29414-1-git-send-email-glasse@cs.rpi.edu>\r
+References: <1328565769-29414-1-git-send-email-glasse@cs.rpi.edu>\r
+User-Agent: Notmuch/0.11+139~g4340989 (http://notmuchmail.org) Emacs/23.3.1\r
+ (i686-pc-linux-gnu)\r
+Date: Tue, 07 Feb 2012 00:21:21 +0200\r
+Message-ID: <878vkfppr2.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Cc: Ethan Glasser-Camp <ethan@betacantrips.com>\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: Mon, 06 Feb 2012 22:21:28 -0000\r
+\r
+On Mon, 6 Feb 2012 17:02:49 -0500, Ethan Glasser-Camp <glasse@cs.rpi.edu> wrote:\r
+> From: Ethan Glasser-Camp <ethan@betacantrips.com>\r
+> \r
+> scandir() returns "strings allocated via malloc(3)" which are then\r
+> "collected in array namelist which is allocated via\r
+> malloc(3)". Currently we just free the array namelist. Instead, free\r
+> all the entries of namelist, and then free namelist.\r
+> \r
+> entry only points to elements of namelist, so we don't free it\r
+> separately.\r
+> ---\r
+> \r
+> This should fix a minor memory leak in notmuch-new. Please confirm I'm\r
+> reading the manpage correctly ;)\r
+\r
+It looks right, good catch! Please do also fix the other scandir() usage\r
+in count_files().\r
+\r
+BR,\r
+Jani.\r
+\r
+\r
+> \r
+> notmuch-new.c | 8 +++++---\r
+> 1 files changed, 5 insertions(+), 3 deletions(-)\r
+> \r
+> diff --git a/notmuch-new.c b/notmuch-new.c\r
+> index a569a54..c536873 100644\r
+> --- a/notmuch-new.c\r
+> +++ b/notmuch-new.c\r
+> @@ -559,12 +559,14 @@ add_files_recursive (notmuch_database_t *notmuch,\r
+> DONE:\r
+> if (next)\r
+> talloc_free (next);\r
+> - if (entry)\r
+> - free (entry);\r
+> if (dir)\r
+> closedir (dir);\r
+> - if (fs_entries)\r
+> + if (fs_entries){\r
+> + for (i = 0; i < num_fs_entries; i++){\r
+> + free (fs_entries[i]);\r
+> + }\r
+> free (fs_entries);\r
+> + }\r
+> if (db_subdirs)\r
+> notmuch_filenames_destroy (db_subdirs);\r
+> if (db_files)\r
+> -- \r
+> 1.7.5.4\r
+> \r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r