[asterisk-dev] ast_frame allocation/free question

Simon Perreault simon.perreault at viagenie.ca
Wed Nov 28 07:03:16 CST 2007


On Wednesday 28 November 2007 07:45:45 Kevin P. Fleming wrote:
> Have you looked at the code for ast_frame_free()? The reason those
> members are there (which is documented in frame.h) is so that
> ast_frame_free() can know which parts (if any) of the frame were
> dynamically allocated and which parts were not. For example, it is
> common to have a non-dynamically-allocated frame header (on the stack or
> static) with dynamically allocated payload. The creator of the ast_frame
> object will make those decisions, and none of the users of the frame
> (*including* the new owner of the frame) need to care about them at all,
> because only ast_frame_free() will react to them. (Technically that is
> not true, as there are ways to duplicate frames as well, and those
> structure members will be taken into account during the copy process,
> and the copied frame will have a different set of flags even though it
> has the same contents).

Thank you very much for this explanation! Just for the record, programming 
with Asterisk in my case is about 90% reading Asterisk's code and 10% writing 
my own. ;)



More information about the asterisk-dev mailing list