[asterisk-commits] seanbright: branch 1.4 r298345 - /branches/1.4/main/astobj2.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Dec 15 21:28:33 UTC 2010
Author: seanbright
Date: Wed Dec 15 15:28:29 2010
New Revision: 298345
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=298345
Log:
Fix reference and container leaks when running 'astobj2 test.'
We need to make sure that ao2_iterator_destroy is called once for each time that
ao2_iterator_init is called. Also make sure to unref a newly allocated object
that we've linked into a container.
Modified:
branches/1.4/main/astobj2.c
Modified: branches/1.4/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.4/main/astobj2.c?view=diff&rev=298345&r1=298344&r2=298345
==============================================================================
--- branches/1.4/main/astobj2.c (original)
+++ branches/1.4/main/astobj2.c Wed Dec 15 15:28:29 2010
@@ -789,6 +789,7 @@
ast_cli(fd, "object %d allocated as %p\n", i, obj);
sprintf(obj, "-- this is obj %d --", i);
ao2_link(c1, obj);
+ ao2_ref(obj, -1);
}
ast_cli(fd, "testing callbacks\n");
ao2_callback(c1, 0, print_cb, &fd);
@@ -805,12 +806,14 @@
ao2_unlink(c1, obj);
ao2_ref(obj, -1);
}
+ ao2_iterator_destroy(&ai);
ast_cli(fd, "testing iterators again\n");
ai = ao2_iterator_init(c1, 0);
while ( (obj = ao2_iterator_next(&ai)) ) {
ast_cli(fd, "iterator on <%s>\n", obj);
ao2_ref(obj, -1);
}
+ ao2_iterator_destroy(&ai);
}
ast_cli(fd, "testing callbacks again\n");
ao2_callback(c1, 0, print_cb, &fd);
More information about the asterisk-commits
mailing list