[asterisk-commits] russell: trunk r81998 - in /trunk: ./ main/asterisk.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Sep 8 13:45:51 CDT 2007
Author: russell
Date: Sat Sep 8 13:45:51 2007
New Revision: 81998
URL: http://svn.digium.com/view/asterisk?view=rev&rev=81998
Log:
Merged revisions 81997 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r81997 | russell | 2007-09-08 13:41:32 -0500 (Sat, 08 Sep 2007) | 2 lines
Fix a small memory leak. ast_unregister_atexit() did not free the entry it removed.
........
Modified:
trunk/ (props changed)
trunk/main/asterisk.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Modified: trunk/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/trunk/main/asterisk.c?view=diff&rev=81998&r1=81997&r2=81998
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Sat Sep 8 13:45:51 2007
@@ -671,22 +671,26 @@
int ast_register_atexit(void (*func)(void))
{
- int res = -1;
struct ast_atexit *ae;
+
+ if (!(ae = ast_calloc(1, sizeof(*ae))))
+ return -1;
+
+ ae->func = func;
+
ast_unregister_atexit(func);
+
AST_RWLIST_WRLOCK(&atexits);
- if ((ae = ast_calloc(1, sizeof(*ae)))) {
- AST_RWLIST_INSERT_HEAD(&atexits, ae, list);
- ae->func = func;
- res = 0;
- }
+ AST_RWLIST_INSERT_HEAD(&atexits, ae, list);
AST_RWLIST_UNLOCK(&atexits);
- return res;
+
+ return 0;
}
void ast_unregister_atexit(void (*func)(void))
{
- struct ast_atexit *ae;
+ struct ast_atexit *ae = NULL;
+
AST_RWLIST_WRLOCK(&atexits);
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&atexits, ae, list) {
if (ae->func == func) {
@@ -696,6 +700,9 @@
}
AST_RWLIST_TRAVERSE_SAFE_END
AST_RWLIST_UNLOCK(&atexits);
+
+ if (ae)
+ free(ae);
}
static int fdprint(int fd, const char *s)
More information about the asterisk-commits
mailing list