Re: Easy mbuf_pullup Question (I hope)
Re: Easy mbuf_pullup Question (I hope)
- Subject: Re: Easy mbuf_pullup Question (I hope)
- From: Terry Lambert <email@hidden>
- Date: Tue, 6 Feb 2007 16:25:36 -0800
On Feb 6, 2007, at 5:49 AM, Andrew Gallatin wrote:
And always assume the mbuf that comes back is a totally new one, and
never reference the old one again. Else you'll be cursed with random,
hard to track down 'freeing free mbuf' panics like I was.
Can you file a kernel KPI bug so we can possibly track proactively
fixing it to make this kind of coding error less likely?
It's really trivial to prevent this sort of thing by changing the API
design, e.g. from:
x_t *
foo(x_t *xp)
{
...
return(newxp);
}
to something like:
x_t *
foo(x_t **xpp)
{
...
*xpp = NULL; /* destroy caller's pointer to prevent use of freed
memory */
return(newxp);
}
to make you fail immediately on continuing to use the pointer that was
foo()'s parameter, instead of failing at some random place later
because of a "memory stomper".
Thanks,
-- Terry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden