[matroska-devel] Re: Memory leaks in libmatroska partially fixed
rbultje at ronald.bitfreak.net
Tue Feb 25 16:19:58 CET 2003
Hey Steve & co,
On Tue, 2003-02-25 at 15:52, Steve Lhomme wrote:
> No that's correct. The allocated memory is not freed because, as I said in the
> previous email, the chidren on "head" are not freed when "head" is (which is an
> EbmlMaster). I'll add something to automatically free these EbmlMaster children.
> I will use a locking system so that if you really want to keep an element in
> memory, you can (and you become the father will all responsabilites ;).
Shouldn't you just use refcounting here?
(short explanation:) Each user of an object ref()s it (incease refcount
with one), and if you're done using it you unref() (decrease refcount
with one) it. The one that created the object (ref() is an implicit part
of object creation) should use unref() too. If noone uses the object,
the refcount is zero (since everyone unref()ed it) and the object is
automagically free()ed (in unref(), a check is done to see whether
refcount is zero - if so, you delete the object).
Ronald Bultje <rbultje at ronald.bitfreak.net>
Linux Video/Multimedia developer
More information about the Matroska-devel