1 Return-Path: <amdragon@mit.edu>
\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 53A9D431FAF
\r
6 for <notmuch@notmuchmail.org>; Wed, 11 Apr 2012 14:11:17 -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 rR43GqcxLqgG for <notmuch@notmuchmail.org>;
\r
16 Wed, 11 Apr 2012 14:11:16 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id A6D3E431FAE
\r
20 for <notmuch@notmuchmail.org>; Wed, 11 Apr 2012 14:11:16 -0700 (PDT)
\r
21 X-AuditID: 1209190f-b7f8a6d000000914-a6-4f85f37497cd
\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])
\r
23 by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id FB.12.02324.473F58F4; Wed, 11 Apr 2012 17:11:16 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q3BLBFVS012680;
\r
27 Wed, 11 Apr 2012 17:11:16 -0400
\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])
\r
29 (authenticated bits=0)
\r
30 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
31 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q3BLBEIm021678
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Wed, 11 Apr 2012 17:11:14 -0400 (EDT)
\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)
\r
35 (envelope-from <amdragon@mit.edu>)
\r
36 id 1SI4or-000184-Mo; Wed, 11 Apr 2012 17:11:13 -0400
\r
37 From: Austin Clements <amdragon@MIT.EDU>
\r
38 To: Jani Nikula <jani@nikula.org>, Vladimir Marek <Vladimir.Marek@Oracle.COM>,
\r
39 Notmuch Mail <notmuch@notmuchmail.org>
\r
40 Subject: Re: [PATCH 4/4] Explicitly type void* pointers
\r
41 In-Reply-To: <87mx6ka8y1.fsf@nikula.org>
\r
42 References: <1333966665-10469-1-git-send-email-Vladimir.Marek@oracle.com>
\r
43 <1333966665-10469-5-git-send-email-Vladimir.Marek@oracle.com>
\r
44 <CAB+hUn_QyMAfC1-Dr23T63ObX=cwuBOzcyCi=61w0MtGRMyt2w@mail.gmail.com>
\r
45 <20120409181543.GC10554@pub.czech.sun.com>
\r
46 <87mx6ka8y1.fsf@nikula.org>
\r
47 User-Agent: Notmuch/0.12+107~gf2d67c3 (http://notmuchmail.org) Emacs/23.3.1
\r
49 Date: Wed, 11 Apr 2012 17:11:13 -0400
\r
50 Message-ID: <87vcl6nfda.fsf@awakening.csail.mit.edu>
\r
52 Content-Type: text/plain; charset=us-ascii
\r
53 X-Brightmail-Tracker:
\r
54 H4sIAAAAAAAAA+NgFnrJIsWRmVeSWpSXmKPExsUixCmqrVvyudXf4NcvIYum6c4W12/OZLbo
\r
55 uL2bzYHZ49b91+wez1bdYvb4+PQWSwBzFJdNSmpOZllqkb5dAldG2+yYgqM8FbMPvmJpYGzh
\r
56 6mLk5JAQMJHY+vMyC4QtJnHh3nq2LkYuDiGBfYwS9w49Z4dwNjBKfL9xmRnCOckk8ad1IRNI
\r
57 i5DAEkaJzt/SIDabgIbEtv3LGUFsEYE6iZmH3rGB2MIC5hIf/09gBrE5gWomv/nMCtE7mUli
\r
58 xj5VEFtUIF5iXcN7sDiLgKrE6UufwebwAp23ufckO4QtKHFy5hOwU5kFtCRu/HvJNIFRYBaS
\r
59 1CwkqQWMTKsYZVNyq3RzEzNzilOTdYuTE/PyUot0TfRyM0v0UlNKNzGCQ1SSfwfjt4NKhxgF
\r
60 OBiVeHh3TWj1F2JNLCuuzD3EKMnBpCTK6/keKMSXlJ9SmZFYnBFfVJqTWnyIUYKDWUmE12V2
\r
61 i78Qb0piZVVqUT5MSpqDRUmcV03rnZ+QQHpiSWp2ampBahFMVoaDQ0mCd8knoKGCRanpqRVp
\r
62 mTklCGkmDk6Q4TxAw+tBaniLCxJzizPTIfKnGBWlxHm7QBICIImM0jy4XlgKecUoDvSKMG8L
\r
63 SBUPMP3Adb8CGswENPjzZJCri0sSEVJSDYzZMi8CTs3uvZzBWCX1pMU9r7tJy7L+v9nnjVyH
\r
64 2S/+3V2uuOHu28y11ytM/OSuuT64/KZSmnnxTf0KiZcHd5p/bGu4zbfCfuYGQ61Zf1s3NzNc
\r
65 XDP35+bp+22SLgb+28a8q6Li41TG0C8rI/5dn/Czr9Jnx7HrIimbI3N69wp93ibx5OLT776t
\r
66 SizFGYmGWsxFxYkAHgFeTfwCAAA=
\r
67 X-BeenThere: notmuch@notmuchmail.org
\r
68 X-Mailman-Version: 2.1.13
\r
70 List-Id: "Use and development of the notmuch mail system."
\r
71 <notmuch.notmuchmail.org>
\r
72 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
73 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
74 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
75 List-Post: <mailto:notmuch@notmuchmail.org>
\r
76 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
77 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
78 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
79 X-List-Received-Date: Wed, 11 Apr 2012 21:11:17 -0000
\r
81 On Mon, 09 Apr 2012, Jani Nikula <jani@nikula.org> wrote:
\r
82 > Vladimir Marek <Vladimir.Marek@Oracle.COM> writes:
\r
83 > I'm throwing in a third alternative below. Does it work for you? I think
\r
84 > it's both prettier and uglier than the above at the same time! ;)
\r
86 > A middle ground would be to change the callers to use
\r
87 > "notmuch_talloc_steal", and just #define notmuch_talloc_steal
\r
88 > talloc_steal if __GNUC__ >= 3.
\r
90 > One could argue upstream talloc should have this, but OTOH it's a C
\r
97 > diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
\r
98 > index ea836f7..83b46e8 100644
\r
99 > --- a/lib/notmuch-private.h
\r
100 > +++ b/lib/notmuch-private.h
\r
101 > @@ -499,4 +499,22 @@ _notmuch_filenames_create (const void *ctx,
\r
103 > NOTMUCH_END_DECLS
\r
105 > +#ifdef __cplusplus
\r
106 > +/* Implicit typecast from 'void *' to 'T *' is okay in C, but not in
\r
107 > + * C++. In talloc_steal, an explicit cast is provided for type safety
\r
108 > + * in some GCC versions. Otherwise, a cast is required. Provide a
\r
109 > + * template function for this to maintain type safety, and redefine
\r
110 > + * talloc_steal to use it.
\r
112 > +#if !(__GNUC__ >= 3)
\r
113 > +template <class T>
\r
114 > +T *notmuch_talloc_steal(const void *new_ctx, const T *ptr)
\r
116 > + return static_cast<T*>(talloc_steal(new_ctx, ptr));
\r
118 > +#undef talloc_steal
\r
119 > +#define talloc_steal notmuch_talloc_steal
\r
125 This looks good to me. I was originally concerned that this depended on
\r
126 talloc_steal being a macro, but I realized that's not actually the case.
\r
127 Care to roll a real patch?
\r