From: David Bremner <david@tethera.net>
To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org
Subject: Re: [RFC PATCH 4/5] cli: change the data structure for notmuch address deduplication
Date: Sat, 29 Aug 2015 22:48:53 -0300 [thread overview]
Message-ID: <87a8t9tuka.fsf@maritornes.cs.unb.ca> (raw)
In-Reply-To: <ffe5975fd070d3e8e22602b01ceb8bf0d7d47ae0.1440859765.git.jani@nikula.org>
Jani Nikula <jani@nikula.org> writes:
>
> +static int
> +strcase_equal (const void *a, const void *b)
> +{
> + return strcasecmp (a, b) == 0;
> +}
> +
> +static unsigned int
> +strcase_hash (const void *ptr)
> +{
> + const char *s = ptr;
> +
> + /* This is the djb2 hash. */
> + unsigned int hash = 5381;
> + while (s && *s) {
> + hash = ((hash << 5) + hash) + tolower (*s);
> + s++;
> + }
> +
> + return hash;
> +}
> +
as discussed, these functions probably need to be factored out into
libutil.
> + l = g_list_find_custom (list, mailbox, mailbox_compare);
> + if (l) {
> + talloc_free (mailbox);
> + mailbox = l->data;
> + mailbox->count++;
> + return TRUE;
> + }
I found this use of mailbox as a temporary variable confusing; despite
the obvious return I thought it might have something to do with the
g_list_append below. Maybe just make a block scope temporary variable?
> +
> + g_list_append (list, mailbox);
> + return FALSE;
> }
>
> - mailbox = new_mailbox (ctx->format, name, addr);
> - if (! mailbox)
> + key = talloc_strdup (ctx->format, addr);
> + if (! key)
> return FALSE;
I guess this doesn't make the error handling worse; both old and new
code silently ignore OOM if I understand correctly. Do you happen to
understand the original choice of using ctx->format rather than that
ctx->notmuch for a talloc parent? it doesn't seem to get deallocated any
earlier.
d
next prev parent reply other threads:[~2015-08-30 1:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-29 14:56 [PATCH 0/5] cli: alternative address deduplication Jani Nikula
2015-08-29 14:56 ` [RFC PATCH 1/5] cli: g_hash_table_lookup_extended is overkill Jani Nikula
2015-08-29 14:56 ` [RFC PATCH 2/5] cli: abstract new mailbox creation Jani Nikula
2015-08-29 14:56 ` [RFC PATCH 3/5] cli: add support for not deduplicating notmuch address results Jani Nikula
2015-08-30 1:29 ` David Bremner
2015-08-30 7:33 ` Jani Nikula
2015-08-29 14:56 ` [RFC PATCH 4/5] cli: change the data structure for notmuch address deduplication Jani Nikula
2015-08-30 1:48 ` David Bremner [this message]
2015-08-30 7:45 ` Jani Nikula
2015-08-30 11:46 ` David Bremner
2015-08-30 7:47 ` Jani Nikula
2015-08-29 14:56 ` [RFC PATCH 5/5] cli: add support for deduplicating based on case insensitive address Jani Nikula
2015-08-30 12:06 ` David Bremner
2015-08-31 10:52 ` Tomi Ollila
2015-08-31 11:15 ` 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=87a8t9tuka.fsf@maritornes.cs.unb.ca \
--to=david@tethera.net \
--cc=jani@nikula.org \
--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).