[asterisk-commits] mmichelson: branch mmichelson/res_sip r378711 - /team/mmichelson/res_sip/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 9 09:30:47 CST 2013


Author: mmichelson
Date: Wed Jan  9 09:30:44 2013
New Revision: 378711

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378711
Log:
Insert identifier into list properly. Free list item when removed from endpoint identifier list.


Modified:
    team/mmichelson/res_sip/res/res_sip.c

Modified: team/mmichelson/res_sip/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/res_sip/res/res_sip.c?view=diff&rev=378711&r1=378710&r2=378711
==============================================================================
--- team/mmichelson/res_sip/res/res_sip.c (original)
+++ team/mmichelson/res_sip/res/res_sip.c Wed Jan  9 09:30:44 2013
@@ -114,8 +114,17 @@
 
 int ast_sip_register_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
 {
+	struct endpoint_identifier_list *id_list_item;
 	SCOPED_LOCK(lock, &endpoint_identifiers, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
-	AST_RWLIST_INSERT_TAIL(&endpoint_identifiers);
+
+	id_list_item = ast_calloc(1, sizeof(*id_list_item));
+	if (!id_list_item) {
+		ast_log(LOG_ERROR, "Unabled to add endpoint identifier. Out of memory.\n");
+		return -1;
+	}
+	id_list_item->identifier = identifier;
+
+	AST_RWLIST_INSERT_TAIL(&endpoint_identifiers, id_list_item, list);
 	ast_debug(1, "Registered endpoint identifier %p\n", identifier);
 }
 
@@ -126,6 +135,7 @@
 	AST_RWLIST_TRAVERSE_SAFE_BEGIN(&endpoint_identifiers, iter, list) {
 		if (iter->identifier == identifier) {
 			AST_RWLIST_REMOVE_CURRENT(list);
+			ast_free(iter);
 			ast_debug(1, "Unregistered endpoint identifier %p\n", identifier);
 			break;
 		}




More information about the asterisk-commits mailing list