Re: [PATCH] lib: work around talloc_steal usage from C++ code

Subject: Re: [PATCH] lib: work around talloc_steal usage from C++ code

Date: Thu, 12 Apr 2012 17:04:14 -0400

To: Jani Nikula

Cc: notmuch@notmuchmail.org

From: Austin Clements


Quoth Jani Nikula on Apr 12 at 11:57 pm:
> Implicit typecast from 'void *' to 'T *' is okay in C, but not in
> C++. In talloc_steal, an explicit cast is provided for type safety in
> some GCC versions. Otherwise, a cast is required. Provide a template
> function for this to maintain type safety, and redefine talloc_steal
> to use it.
> 
> The template must be outside the extern "C" block (NOTMUCH_BEGIN_DECLS
> and NOTMUCH_END_DECLS), but keep it within the GCC visibility #pragma.
> 
> No functional changes, apart from making the library build with
> compilers other than recent GCC.
> 
> Signed-off-by: Jani Nikula <jani@nikula.org>

LGTM.

Thread: