Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 0e / a1b9fecc48506a4f47c6b70d46d17e8b48b8a1
1 Return-Path: <beheerder@tekenbeetziekten.nl>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 5C0E5431FB6\r
6         for <notmuch@notmuchmail.org>; Sun,  3 Feb 2013 10:52:34 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id mlsuUvolgfTp for <notmuch@notmuchmail.org>;\r
16         Sun,  3 Feb 2013 10:52:32 -0800 (PST)\r
17 Received: from srv047132.webreus.nl (srv047132.webreus.nl [46.235.47.132])\r
18         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id A1F5D431FAE\r
21         for <notmuch@notmuchmail.org>; Sun,  3 Feb 2013 10:52:31 -0800 (PST)\r
22 Received: (qmail 25815 invoked from network); 3 Feb 2013 19:52:28 +0100\r
23 Received: from ip73-109-210-87.adsl2.static.versatel.nl (HELO linux2.foo)\r
24         (87.210.109.73)\r
25         by srv047132.webreus.nl with SMTP; 3 Feb 2013 19:52:27 +0100\r
26 From: Robert Mast <beheerder@tekenbeetziekten.nl>\r
27 To: notmuch@notmuchmail.org\r
28 Subject: [PATCH] This patch is a little finger excercise for working with git.\r
29         I found a piece of code that I didn't understand at first.\r
30 Date: Sun,  3 Feb 2013 19:51:31 +0100\r
31 Message-Id: <1359917491-17178-1-git-send-email-beheerder@tekenbeetziekten.nl>\r
32 X-Mailer: git-send-email 1.7.9.5\r
33 Cc: Robert Mast <beheerder@tekenbeetziekten.nl>\r
34 X-BeenThere: notmuch@notmuchmail.org\r
35 X-Mailman-Version: 2.1.13\r
36 Precedence: list\r
37 List-Id: "Use and development of the notmuch mail system."\r
38         <notmuch.notmuchmail.org>\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
40         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
42 List-Post: <mailto:notmuch@notmuchmail.org>\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
46 X-List-Received-Date: Sun, 03 Feb 2013 18:52:34 -0000\r
47 \r
48 Reading it in detail I thought it allocated way too much memory and\r
49 didn't use the full size of the allocated unsigned ints for storing\r
50 bits.\r
51 \r
52 Am I right, and is this the right way to patch code to notmuch?\r
53 \r
54 ---\r
55  lib/query.cc |    6 +++---\r
56  1 file changed, 3 insertions(+), 3 deletions(-)\r
57 \r
58 diff --git a/lib/query.cc b/lib/query.cc\r
59 index e9c1a2d..046663a 100644\r
60 --- a/lib/query.cc\r
61 +++ b/lib/query.cc\r
62 @@ -43,8 +43,8 @@ struct _notmuch_doc_id_set {\r
63      unsigned int bound;\r
64  };\r
65  \r
66 -#define DOCIDSET_WORD(bit) ((bit) / sizeof (unsigned int))\r
67 -#define DOCIDSET_BIT(bit) ((bit) % sizeof (unsigned int))\r
68 +#define DOCIDSET_WORD(bit) ((bit) / (sizeof (unsigned int) * CHAR_BIT))\r
69 +#define DOCIDSET_BIT(bit) ((bit) % (sizeof (unsigned int) * CHAR_BIT))\r
70  \r
71  struct visible _notmuch_threads {\r
72      notmuch_query_t *query;\r
73 @@ -363,7 +363,7 @@ _notmuch_doc_id_set_init (void *ctx,\r
74  \r
75      for (unsigned int i = 0; i < arr->len; i++)\r
76         max = MAX(max, g_array_index (arr, unsigned int, i));\r
77 -    bitmap = talloc_zero_array (ctx, unsigned int, 1 + max / sizeof (*bitmap));\r
78 +    bitmap = talloc_zero_array (ctx, unsigned int, (DOCIDSET_WORD(max) + 1) * sizeof (*bitmap));\r
79  \r
80      if (bitmap == NULL)\r
81         return FALSE;\r
82 -- \r
83 1.7.9.5\r
84 \r