[PATCH] This patch is a little finger excercise for working with git. I found a piece...
authorRobert Mast <beheerder@tekenbeetziekten.nl>
Sun, 3 Feb 2013 18:51:31 +0000 (19:51 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:53:28 +0000 (09:53 -0800)
0e/a1b9fecc48506a4f47c6b70d46d17e8b48b8a1 [new file with mode: 0644]

diff --git a/0e/a1b9fecc48506a4f47c6b70d46d17e8b48b8a1 b/0e/a1b9fecc48506a4f47c6b70d46d17e8b48b8a1
new file mode 100644 (file)
index 0000000..f2756d0
--- /dev/null
@@ -0,0 +1,84 @@
+Return-Path: <beheerder@tekenbeetziekten.nl>\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 5C0E5431FB6\r
+       for <notmuch@notmuchmail.org>; Sun,  3 Feb 2013 10:52:34 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       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 mlsuUvolgfTp for <notmuch@notmuchmail.org>;\r
+       Sun,  3 Feb 2013 10:52:32 -0800 (PST)\r
+Received: from srv047132.webreus.nl (srv047132.webreus.nl [46.235.47.132])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id A1F5D431FAE\r
+       for <notmuch@notmuchmail.org>; Sun,  3 Feb 2013 10:52:31 -0800 (PST)\r
+Received: (qmail 25815 invoked from network); 3 Feb 2013 19:52:28 +0100\r
+Received: from ip73-109-210-87.adsl2.static.versatel.nl (HELO linux2.foo)\r
+       (87.210.109.73)\r
+       by srv047132.webreus.nl with SMTP; 3 Feb 2013 19:52:27 +0100\r
+From: Robert Mast <beheerder@tekenbeetziekten.nl>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] This patch is a little finger excercise for working with git.\r
+       I found a piece of code that I didn't understand at first.\r
+Date: Sun,  3 Feb 2013 19:51:31 +0100\r
+Message-Id: <1359917491-17178-1-git-send-email-beheerder@tekenbeetziekten.nl>\r
+X-Mailer: git-send-email 1.7.9.5\r
+Cc: Robert Mast <beheerder@tekenbeetziekten.nl>\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, 03 Feb 2013 18:52:34 -0000\r
+\r
+Reading it in detail I thought it allocated way too much memory and\r
+didn't use the full size of the allocated unsigned ints for storing\r
+bits.\r
+\r
+Am I right, and is this the right way to patch code to notmuch?\r
+\r
+---\r
+ lib/query.cc |    6 +++---\r
+ 1 file changed, 3 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/lib/query.cc b/lib/query.cc\r
+index e9c1a2d..046663a 100644\r
+--- a/lib/query.cc\r
++++ b/lib/query.cc\r
+@@ -43,8 +43,8 @@ struct _notmuch_doc_id_set {\r
+     unsigned int bound;\r
+ };\r
\r
+-#define DOCIDSET_WORD(bit) ((bit) / sizeof (unsigned int))\r
+-#define DOCIDSET_BIT(bit) ((bit) % sizeof (unsigned int))\r
++#define DOCIDSET_WORD(bit) ((bit) / (sizeof (unsigned int) * CHAR_BIT))\r
++#define DOCIDSET_BIT(bit) ((bit) % (sizeof (unsigned int) * CHAR_BIT))\r
\r
+ struct visible _notmuch_threads {\r
+     notmuch_query_t *query;\r
+@@ -363,7 +363,7 @@ _notmuch_doc_id_set_init (void *ctx,\r
\r
+     for (unsigned int i = 0; i < arr->len; i++)\r
+       max = MAX(max, g_array_index (arr, unsigned int, i));\r
+-    bitmap = talloc_zero_array (ctx, unsigned int, 1 + max / sizeof (*bitmap));\r
++    bitmap = talloc_zero_array (ctx, unsigned int, (DOCIDSET_WORD(max) + 1) * sizeof (*bitmap));\r
\r
+     if (bitmap == NULL)\r
+       return FALSE;\r
+-- \r
+1.7.9.5\r
+\r