talloc: problem with talloc_steal usage from C++

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri Apr 13 12:32:16 MDT 2012


On Fri, Apr 13, 2012 at 12:32:24AM +0300, Jani Nikula wrote:
> Recently, an issue came up with using talloc_steal() in C++ code. For
> recent GCC, talloc.h has some macro magic to provide type safety for
> talloc_steal(). Otherwise, it returns a 'void *', which is okay to
> assign to a non-void pointer in C, but not in C++. An explicit cast
> would be required, losing the type safety for recent GCC, which is not
> very nice if you want to support both GCC and non-GCC compilers.
> 
> As a workaround in the notmuch project, I proposed [1]. Slightly hacky,
> but maintains type safety and does not require any changes in
> talloc_steal() callers. Now if this was done directly in talloc.h, it
> would not be hacky at all... *hint* ;)
> 
> It's a corner case in many ways, and talloc is a C library, so you may
> not be interested, but this is just to let you know such an issue
> exists.
> 
> [1] http://mid.gmane.org/1334264259-17632-1-git-send-email-jani@nikula.org

Not knowing C++ at all if this makes talloc more usable in
that language, you got my +1 if you replace the _notmuch_
with something more generic.

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de


More information about the samba-technical mailing list