From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id sM1qOv9ZDWDVNAAA0tVLHw (envelope-from ) for ; Sun, 24 Jan 2021 11:29:03 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 8Jw8Nv9ZDWDLPgAA1q6Kng (envelope-from ) for ; Sun, 24 Jan 2021 11:29:03 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0E2E89403E8 for ; Sun, 24 Jan 2021 11:29:01 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id BFE6B29D1B; Sun, 24 Jan 2021 06:28:52 -0500 (EST) Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [185.185.170.37]) by mail.notmuchmail.org (Postfix) with ESMTPS id 24B111FF9D for ; Sun, 24 Jan 2021 06:28:48 -0500 (EST) Received: from guru.guru-group.fi (unknown [IPv6:2a02:2380:1:9:5054:ff:feb7:a4bc]) (using TLSv1.2 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: too) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 398021B0011D; Sun, 24 Jan 2021 13:28:45 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1611487725; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mpQrwoYAB9X7mFm/0Mdx3EBftePHIZjuax1Hbi7Zv4k=; b=knvrldpmrbRqwSss+wjIDPHe/IOBwSx58EKnalfIUs0/HJ3ByMYxuRexSZI3+SsMlnchNL IX5mJtYMhlmQApuoPbKfkH6dnRUU06g84E9cEurQGcjCvBHMyhzXhTYJLPAu0lTbh12HAe jCdmO/E7w5YueCUZmeMB1lfJBYtXFYbVKB0NK4A0d9P+hTdB/Ki+hNa38qdzWvhwz82ADO VRx/WuFj0GMkvgvQPdY5CRE57IGzsCaaQVSJ+DBf3YARxalK7w+Usr6kGHntlyadYXfiGJ h9B+RGkZ9XuoCE3WlOlorJOzDzMxhKrpNXGHdpruvBExZ67idfbiz/TTH9f6yA== From: Tomi Ollila To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH 01/38] lib: add _notmuch_string_map_set In-Reply-To: <20210116170406.842014-2-david@tethera.net> References: <20210116170406.842014-1-david@tethera.net> <20210116170406.842014-2-david@tethera.net> User-Agent: Notmuch/0.31.3+85~g92bd77f (https://notmuchmail.org) Emacs/27.1 X-Face: HhBM'cA~ MIME-Version: 1.0 ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1611487725; a=rsa-sha256; cv=none; b=DRf/AJGFfBz41yDLTFtV0Sc/ZM7QL7rd2y1ZM8tWccAiTddvFIj671OFG99U2rYk/5Gib4 MEx15rwaPDlU8EyPsh2zDW/zOqZzMgG6yOXJiYmDivK/W78FypqVoly21uXiF8LqfoXOcq mRs1HUvy8lRn4aZ+SLb/rT2yQAupJofKvQjcCsYoQNCSCPFNr0BwacyvfBMc+T+WF2mIx5 +d9239K2q2Ayhik35ZBk5VFlCJ+N33Tz2Rh9RMQ9u49EtXAf1zA8ZaZoRiYYPLANi6/EP/ c63hEwaItlVMwrlHNJzAZERdrGUPExrrt/EdFf77D2mWifkzMYiWJRXPcpAf9g== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=too smtp.mailfrom=tomi.ollila@iki.fi ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1611487725; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mpQrwoYAB9X7mFm/0Mdx3EBftePHIZjuax1Hbi7Zv4k=; b=AgG7eS+usr2sgivR7QOrIRISve0sMfWl+nyfPpSIN6bXvVHObKwJrADP4TTtnZbO7gx9fI p7oBoxUQYwOnFXNgPGA6hQA75a+a8IQ1rHkO1Jw8zooPaRgvTDvJs1TUQkYXzt+my394Zd nQELk+i704SDCgYiSeMCPzDef1txUF1KIG6QjftV5Y/RsH73vXA950gEMuC6DePtOlyvxM tnWhqXDJTcz8ewGBDRv9AmxOIntNsvoRjUOkpy+rxpIqPrasU/R33LFlct0qq1+6TTwHNu SHfqvdk3btJvcIfXgVL1PXzpXPRqMwfAoKGkFCPHTUH1Br0lwKUOVitUDO1+yA== Message-ID-Hash: SF3RS6MJ4S2QBGZ253KKC26XNN3Z2DHM X-Message-ID-Hash: SF3RS6MJ4S2QBGZ253KKC26XNN3Z2DHM X-MailFrom: tomi.ollila@iki.fi X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 1.13 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b=knvrldpm; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 0E2E89403E8 X-Spam-Score: 1.13 X-Migadu-Scanner: scn1.migadu.com X-TUID: tFEOkmlM1nen On Sat, Jan 16 2021, David Bremner wrote: First, is this patch series safe to be applied and put into use ? :D I've looked this through once. So much stuff hard to figure out if there is something broken. Most of the comments here and other patches are about style (line break), but some (IIRC at least 2) which changes functionality a bit... > This will be used (and tested) by the configuration caching code to be > added in the next commit. > --- > lib/notmuch-private.h | 5 +++++ > lib/string-map.c | 15 +++++++++++++++ > 2 files changed, 20 insertions(+) > > diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h > index 57ec7f72..51016b0b 100644 > --- a/lib/notmuch-private.h > +++ b/lib/notmuch-private.h > @@ -638,6 +638,11 @@ _notmuch_string_map_append (notmuch_string_map_t *map, > const char *key, > const char *value); > > +void > +_notmuch_string_map_set (notmuch_string_map_t *map, > + const char *key, > + const char *value); > + > const char * > _notmuch_string_map_get (notmuch_string_map_t *map, const char *key); > > diff --git a/lib/string-map.c b/lib/string-map.c > index a88404c7..1f3215fb 100644 > --- a/lib/string-map.c > +++ b/lib/string-map.c > @@ -142,6 +142,21 @@ bsearch_first (notmuch_string_pair_t *array, size_t len, const char *key, bool e > return NULL; > > } > +void > +_notmuch_string_map_set (notmuch_string_map_t *map, const char *key, const char *val) The style in string-map.c (and matches the .h above) would indicate the abobe should be: _notmuch_string_map_set (notmuch_string_map_t *map, const char *key, const char *val) > +{ > + notmuch_string_pair_t *pair; > + > + /* this means that calling string_map_set invalidates iterators */ > + _notmuch_string_map_sort (map); > + pair = bsearch_first (map->pairs, map->length, key, true); > + if (! pair) > + _notmuch_string_map_append (map, key, val); > + else { > + talloc_free (pair->value); > + pair->value = talloc_strdup (map->pairs, val); > + } > +} > > const char * > _notmuch_string_map_get (notmuch_string_map_t *map, const char *key) > -- > 2.29.2