Re: [Libguestfs] [libnbd PATCH] RFC: generator: Mark APIs with allocator/deallocator semantics

2022-09-30 Thread Eric Blake
On Fri, Sep 30, 2022 at 05:27:00PM +0100, Richard W.M. Jones wrote: > On Fri, Sep 30, 2022 at 10:42:01AM -0500, Eric Blake wrote: > > Modern GCC has two related attributes for functions returning a > > pointer: > > > > __attribute__((__malloc__)) - this function returns a new pointer, not > >

Re: [Libguestfs] [libnbd PATCH] RFC: generator: Mark APIs with allocator/deallocator semantics

2022-09-30 Thread Richard W.M. Jones
On Fri, Sep 30, 2022 at 10:42:01AM -0500, Eric Blake wrote: > Modern GCC has two related attributes for functions returning a > pointer: > > __attribute__((__malloc__)) - this function returns a new pointer, not > aliased to any existing pointer > > __attribute__((__malloc__(fn,1))) - call

[Libguestfs] [libnbd PATCH] RFC: generator: Mark APIs with allocator/deallocator semantics

2022-09-30 Thread Eric Blake
Modern GCC has two related attributes for functions returning a pointer: __attribute__((__malloc__)) - this function returns a new pointer, not aliased to any existing pointer __attribute__((__malloc__(fn,1))) - call fn(return_value) to avoid leaking memory allocated by this function With those