From: Robert Mast <beheerder@tekenbeetziekten.nl>
To: notmuch@notmuchmail.org
Cc: Robert Mast <beheerder@tekenbeetziekten.nl>
Subject: [PATCH] This patch is a little finger excercise for working with git. I found a piece of code that I didn't understand at first.
Date: Sun, 3 Feb 2013 19:51:31 +0100 [thread overview]
Message-ID: <1359917491-17178-1-git-send-email-beheerder@tekenbeetziekten.nl> (raw)
Reading it in detail I thought it allocated way too much memory and
didn't use the full size of the allocated unsigned ints for storing
bits.
Am I right, and is this the right way to patch code to notmuch?
---
lib/query.cc | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/query.cc b/lib/query.cc
index e9c1a2d..046663a 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -43,8 +43,8 @@ struct _notmuch_doc_id_set {
unsigned int bound;
};
-#define DOCIDSET_WORD(bit) ((bit) / sizeof (unsigned int))
-#define DOCIDSET_BIT(bit) ((bit) % sizeof (unsigned int))
+#define DOCIDSET_WORD(bit) ((bit) / (sizeof (unsigned int) * CHAR_BIT))
+#define DOCIDSET_BIT(bit) ((bit) % (sizeof (unsigned int) * CHAR_BIT))
struct visible _notmuch_threads {
notmuch_query_t *query;
@@ -363,7 +363,7 @@ _notmuch_doc_id_set_init (void *ctx,
for (unsigned int i = 0; i < arr->len; i++)
max = MAX(max, g_array_index (arr, unsigned int, i));
- bitmap = talloc_zero_array (ctx, unsigned int, 1 + max / sizeof (*bitmap));
+ bitmap = talloc_zero_array (ctx, unsigned int, (DOCIDSET_WORD(max) + 1) * sizeof (*bitmap));
if (bitmap == NULL)
return FALSE;
--
1.7.9.5
next reply other threads:[~2013-02-03 18:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-03 18:51 Robert Mast [this message]
2013-02-03 20:01 ` [PATCH] This patch is a little finger excercise for working with git. I found a piece of code that I didn't understand at first Austin Clements
2013-02-10 13:13 ` [PATCH] convert bitmap to unsigned char Robert Mast
2013-02-11 18:56 ` Carl Worth
2013-02-10 17:24 ` [PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR Robert Mast
2013-02-13 15:11 ` Robert Mast
2013-02-13 15:15 ` [english 100%] " Robert Mast
2013-02-13 15:32 ` Robert Mast
2013-02-13 16:21 ` Carl Worth
2013-02-16 11:37 ` David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1359917491-17178-1-git-send-email-beheerder@tekenbeetziekten.nl \
--to=beheerder@tekenbeetziekten.nl \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).