--- /dev/null
+Return-Path: <dmitry.kurochkin@gmail.com>\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 D5B5B431FB6\r
+ for <notmuch@notmuchmail.org>; Tue, 7 Feb 2012 00:34:27 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, 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 6wZRtckBnmTc for <notmuch@notmuchmail.org>;\r
+ Tue, 7 Feb 2012 00:34:27 -0800 (PST)\r
+Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com\r
+ [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id C199C431FAE\r
+ for <notmuch@notmuchmail.org>; Tue, 7 Feb 2012 00:34:26 -0800 (PST)\r
+Received: by bke11 with SMTP id 11so6228204bke.26\r
+ for <notmuch@notmuchmail.org>; Tue, 07 Feb 2012 00:34:25 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+ h=from:to:cc:subject:in-reply-to:references:user-agent:date\r
+ :message-id:mime-version:content-type;\r
+ bh=XWvVEsew+3MQRJA+TjhueiSyWOV0QNnhiVO1YF/QOGc=;\r
+ b=H5/D33/rgpGEWikmvIPOtrHJxnjvO8/ii/nDK5g1RGK/4MeXFnCR38amQRHjVGunSP\r
+ D8O8yEOfJf9qD2qj4DIADwsEQIF0pIw8BrZEC65cUGxoZFt143lw9DjMzZVZjdv/urYI\r
+ rP+YMiKPFNNA9E3NxKhqfC5ysV/h3/zP3vA8Y=\r
+Received: by 10.205.133.196 with SMTP id hz4mr3033097bkc.71.1328603664719;\r
+ Tue, 07 Feb 2012 00:34:24 -0800 (PST)\r
+Received: from localhost ([91.144.186.21])\r
+ by mx.google.com with ESMTPS id bw9sm53347216bkb.8.2012.02.07.00.34.23\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Tue, 07 Feb 2012 00:34:23 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: Ethan Glasser-Camp <glasse@cs.rpi.edu>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2] Free the results of scandir()\r
+In-Reply-To: <1328597405-6437-1-git-send-email-glasse@cs.rpi.edu>\r
+References: <1328597405-6437-1-git-send-email-glasse@cs.rpi.edu>\r
+User-Agent: Notmuch/0.11+139~gd9b7cab (http://notmuchmail.org) Emacs/23.3.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Tue, 07 Feb 2012 12:33:08 +0400\r
+Message-ID: <871uq7yrej.fsf@gmail.com>\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: Tue, 07 Feb 2012 08:34:28 -0000\r
+\r
+Hi Ethan.\r
+\r
+On Tue, 7 Feb 2012 01:50:05 -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
+> Fixes the other use of scandir in count_files. Thanks, Jani.\r
+> \r
+\r
+Few style comments below. Otherwise looks good.\r
+\r
+> notmuch-new.c | 16 ++++++++++------\r
+> 1 files changed, 10 insertions(+), 6 deletions(-)\r
+> \r
+> diff --git a/notmuch-new.c b/notmuch-new.c\r
+> index a569a54..e62560b 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
+\r
+Please add a space before '{'.\r
+\r
+> + for (i = 0; i < num_fs_entries; i++){\r
+> + free (fs_entries[i]);\r
+> + }\r
+\r
+Please remove "{}" around one line block.\r
+\r
+> free (fs_entries);\r
+> + }\r
+> if (db_subdirs)\r
+> notmuch_filenames_destroy (db_subdirs);\r
+> if (db_files)\r
+> @@ -704,10 +706,12 @@ count_files (const char *path, int *count)\r
+> }\r
+> \r
+> DONE:\r
+> - if (entry)\r
+> - free (entry);\r
+> - if (fs_entries)\r
+> + if (fs_entries){\r
+> + for (i = 0; i < num_fs_entries; i++){\r
+> + free (fs_entries[i]);\r
+> + }\r
+\r
+Same two comments here.\r
+\r
+Regards,\r
+ Dmitry\r
+\r
+> free (fs_entries);\r
+> + }\r
+> }\r
+> \r
+> static void\r
+> -- \r
+> 1.7.5.4\r
+> \r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r