[ccan] RFC: draft rfc822 module

Rusty Russell rusty at rustcorp.com.au
Wed May 23 22:08:30 EST 2012


On Tue, 22 May 2012 23:37:32 +1000, David Gibson <david at gibson.dropbear.id.au> wrote:
> On Tue, May 22, 2012 at 01:35:14PM +0930, Paul 'Rusty' Russell wrote:
> > Error handling could be done here:
> > 
> >         static void *myalloc(struct rfc822 *msg, size_t len)
> >         {
> >                 void *ret = talloc(msg, len);
> >                 if (!ret) {
> >                         struct myrfc822 *mymsg = (struct myrfc822 *)msg;
> >                         mymsg->alloc_failed++;
> >                 }
> >                 return ret;
> >         }
> 
> I don't quite see what that does differently from what I already
> have.  It already requires talloc, and internal data structures are
> allocated using the message structure as a context.

Indeed.  Since ccan/talloc lets you set the alloc functions already,
your error handing function is redundant.

However, default talloc doesn't... so might as well leave it as it is,
with a global handler.

Cheers,
Rusty.


More information about the ccan mailing list