1 Return-Path: <jani@nikula.org>
\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 7F44A431FAF
\r
6 for <notmuch@notmuchmail.org>; Thu, 12 Apr 2012 01:02:29 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 4GpkA7WFyGZ9 for <notmuch@notmuchmail.org>;
\r
16 Thu, 12 Apr 2012 01:02:21 -0700 (PDT)
\r
17 Received: from mail-qc0-f181.google.com (mail-qc0-f181.google.com
\r
18 [209.85.216.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 778A8431FAE
\r
21 for <notmuch@notmuchmail.org>; Thu, 12 Apr 2012 01:02:21 -0700 (PDT)
\r
22 Received: by qcsk26 with SMTP id k26so1328663qcs.26
\r
23 for <notmuch@notmuchmail.org>; Thu, 12 Apr 2012 01:02:20 -0700 (PDT)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=google.com; s=20120113;
\r
26 h=from:to:subject:in-reply-to:references:user-agent:date:message-id
\r
27 :mime-version:content-type:x-gm-message-state;
\r
28 bh=DRB71CSZOX2WgFOFU4c+gC7k1b/2jSlhJMRtQ4ltaGE=;
\r
29 b=YqFJpcR9XrrGL58AO1LsONVbna6kvdjr8IJTrosleT1SONaK8xiCHrxNCDXqXeJwZM
\r
30 yHOyzJks+h2IMVKyVAr/EkOENl5YWXgnTJProH0HyMFLqDk0pQiFKjLBq16570bLf+qO
\r
31 8PcGbKv+p8MiQtEgCU5Cpm7r5opfJAvACqPwLJL72gMrXHemI/ge/ygznvDXMjJudD6d
\r
32 xXWesY8e6CZETLBGN1qZ+tOsbyYrAsbqtSAF528P8vyknQvcY8hmG9Go402C+H+Qykbq
\r
33 tIytdsVucnU3K5LJl5ZIQIgYehkhRv2WwHY15byxIXvMy8nb+zAuReI7eaOPIPA1hoVA
\r
35 Received: by 10.224.221.75 with SMTP id ib11mr2610027qab.21.1334217739927;
\r
36 Thu, 12 Apr 2012 01:02:19 -0700 (PDT)
\r
37 Received: from localhost ([92.243.24.172])
\r
38 by mx.google.com with ESMTPS id cs10sm10466237qab.8.2012.04.12.01.02.17
\r
39 (version=SSLv3 cipher=OTHER); Thu, 12 Apr 2012 01:02:18 -0700 (PDT)
\r
40 From: Jani Nikula <jani@nikula.org>
\r
41 To: Austin Clements <amdragon@MIT.EDU>,
\r
42 Vladimir Marek <Vladimir.Marek@Oracle.COM>,
\r
43 Notmuch Mail <notmuch@notmuchmail.org>
\r
44 Subject: Re: [PATCH 4/4] Explicitly type void* pointers
\r
45 In-Reply-To: <87vcl6nfda.fsf@awakening.csail.mit.edu>
\r
46 References: <1333966665-10469-1-git-send-email-Vladimir.Marek@oracle.com>
\r
47 <1333966665-10469-5-git-send-email-Vladimir.Marek@oracle.com>
\r
48 <CAB+hUn_QyMAfC1-Dr23T63ObX=cwuBOzcyCi=61w0MtGRMyt2w@mail.gmail.com>
\r
49 <20120409181543.GC10554@pub.czech.sun.com>
\r
50 <87mx6ka8y1.fsf@nikula.org>
\r
51 <87vcl6nfda.fsf@awakening.csail.mit.edu>
\r
52 User-Agent: Notmuch/0.11.1+222~ga47a98c (http://notmuchmail.org) Emacs/23.1.1
\r
54 Date: Thu, 12 Apr 2012 08:02:12 +0000
\r
55 Message-ID: <87aa2hxtrv.fsf@nikula.org>
\r
57 Content-Type: text/plain; charset=us-ascii
\r
59 ALoCoQl3XkMe5Epw3Hd9TfIVATcin2Ntgpcu1FQ4n7AcqDB0tcYSs+bEG23kBpsm3ON0d/DCWvvn
\r
60 X-BeenThere: notmuch@notmuchmail.org
\r
61 X-Mailman-Version: 2.1.13
\r
63 List-Id: "Use and development of the notmuch mail system."
\r
64 <notmuch.notmuchmail.org>
\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
68 List-Post: <mailto:notmuch@notmuchmail.org>
\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
71 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
72 X-List-Received-Date: Thu, 12 Apr 2012 08:02:29 -0000
\r
74 On Wed, 11 Apr 2012 17:11:13 -0400, Austin Clements <amdragon@MIT.EDU> wrote:
\r
75 > On Mon, 09 Apr 2012, Jani Nikula <jani@nikula.org> wrote:
\r
76 > > Vladimir Marek <Vladimir.Marek@Oracle.COM> writes:
\r
77 > > I'm throwing in a third alternative below. Does it work for you? I think
\r
78 > > it's both prettier and uglier than the above at the same time! ;)
\r
80 > > A middle ground would be to change the callers to use
\r
81 > > "notmuch_talloc_steal", and just #define notmuch_talloc_steal
\r
82 > > talloc_steal if __GNUC__ >= 3.
\r
84 > > One could argue upstream talloc should have this, but OTOH it's a C
\r
91 > > diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
\r
92 > > index ea836f7..83b46e8 100644
\r
93 > > --- a/lib/notmuch-private.h
\r
94 > > +++ b/lib/notmuch-private.h
\r
95 > > @@ -499,4 +499,22 @@ _notmuch_filenames_create (const void *ctx,
\r
97 > > NOTMUCH_END_DECLS
\r
99 > > +#ifdef __cplusplus
\r
100 > > +/* Implicit typecast from 'void *' to 'T *' is okay in C, but not in
\r
101 > > + * C++. In talloc_steal, an explicit cast is provided for type safety
\r
102 > > + * in some GCC versions. Otherwise, a cast is required. Provide a
\r
103 > > + * template function for this to maintain type safety, and redefine
\r
104 > > + * talloc_steal to use it.
\r
106 > > +#if !(__GNUC__ >= 3)
\r
107 > > +template <class T>
\r
108 > > +T *notmuch_talloc_steal(const void *new_ctx, const T *ptr)
\r
110 > > + return static_cast<T*>(talloc_steal(new_ctx, ptr));
\r
112 > > +#undef talloc_steal
\r
113 > > +#define talloc_steal notmuch_talloc_steal
\r
119 > This looks good to me. I was originally concerned that this depended on
\r
120 > talloc_steal being a macro, but I realized that's not actually the case.
\r
121 > Care to roll a real patch?
\r
125 One question: the template must be outside NOTMUCH_{BEGIN,END}_DECLS
\r
126 (which are just macros for extern "C" block) but should it be within the
\r
127 #pragma GCC visibility push(hidden) and pop directives? I'm not familiar
\r
130 Thanks for the review.
\r