[asterisk-dev] ast_frame allocation/free question

Sergio Garcia Murillo sergio.garcia at fontventa.com
Tue Nov 27 14:06:59 CST 2007


From: "Kevin P. Fleming" <kpfleming at digium.com>
> Sergio Garcia Murillo wrote:
>
> > So if you're writting a custom application you have to take care for
> > deleting the
> > frames you write and the frames you read, but if you write a custom
channel
> > you
> > don't have to worry?
> > Shouldn't be better to have a general policy about it, for example the
one
> > that creates
> > the frame has to take care of deleting it, or the one that consumes the
> > frame is the one
> > that  deletes it. Just as an idea, as I said before I've just made
> > everything static and
> > fixed my problem.
>
> So what is your definition of 'consume'? The application you are writing
> is the one that is 'consuming' the frames. If ast_write() was the
> consumer, then you'd never be able to write the frame to more than one
> location without duplicating it, which would be needless overhead.
>

I agree, but I think that it's a usually a good practice that the one that
allocates
the memory is the reponsible of freeing it. What I don't really see is why
the
apps need to call the ast_frfree on frames they have just readen.
Also as Russell pointed I perhaps should be using the ast_frame_header_new()
if i really need to dinamically allocate frames.

BR
Sergio





More information about the asterisk-dev mailing list