prevent reference promotion to owner
authorSam Liddicott <sam@liddicott.com>
Fri, 10 Jul 2009 10:35:16 +0000 (11:35 +0100)
committerStefan Metzmacher <metze@samba.org>
Mon, 13 Jul 2009 18:54:30 +0000 (20:54 +0200)
commit95c37860b2d58c34717139f70d0632e1165451f4
tree189123ad9e246b71d82546181d14d4645e3b7362
parent5e4ee76e29add15cde392d74a8fdf074aa7ca6d4
prevent reference promotion to owner

The new rules are:

1. if you talloc() you must make preparation to free.
Usually the allocating reference being freed is enough, otherwise
explicitly talloc_free.

2. if you talloc_steal you must make preparation to free.
Usually the stealing reference being freed is enough, otherwise
explicitly talloc_free.

3. if you talloc_reference something you must make preparation to
remove the reference. Usually the reference itself being freed
is enough

4. you only call talloc_free once, on behalf of the allocator
or the stealer. If you want to remove a reference, then use
talloc_unreference

5. A function that calls talloc_free on an object has by definition
a passing-of-ownership in it's operation, and callers of the
function ought to be aware of this.

6. the destructor is called when the object is freed, not when
you call talloc_free. References might keep it alive for quite a while.

Signed-off-by: Sam Liddicott <sam@liddicott.com>
lib/talloc/talloc.c