[asterisk-commits] trunk r26800 - /trunk/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu May 11 02:29:38 MST 2006


Author: rizzo
Date: Thu May 11 04:29:37 2006
New Revision: 26800

URL: http://svn.digium.com/view/asterisk?rev=26800&view=rev
Log:
replace list unlinking with UNLINK macro
(when the list becomes an astobj this will be revisited;
however at the moment the change would be too intrusive).


Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=26800&r1=26799&r2=26800&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu May 11 04:29:37 2006
@@ -1259,6 +1259,15 @@
 	.send_text = sip_sendtext,
 };
 
+/**--- some list management macros. **/
+ 
+#define UNLINK(element, head, prev) do {	\
+	if (prev)				\
+		(prev)->next = (element)->next;	\
+	else					\
+		(head) = (element)->next;	\
+	} while (0)
+
 /*! \brief Interface structure with callbacks used to connect to RTP module */
 static struct ast_rtp_protocol sip_rtp = {
 	type: "SIP",
@@ -1716,10 +1725,7 @@
 				p->pendinginvite = 0;
 			}
 			/* this is our baby */
-			if (prev)
-				prev->next = cur->next;
-			else
-				p->packets = cur->next;
+			UNLINK(cur, p->packets, prev);
 			if (cur->retransid > -1) {
 				if (sipdebug && option_debug > 3)
 					ast_log(LOG_DEBUG, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
@@ -2487,10 +2493,7 @@
 
 	for (prev = NULL, cur = iflist; cur; prev = cur, cur = cur->next) {
 		if (cur == p) {
-			if (prev)
-				prev->next = cur->next;
-			else
-				iflist = cur->next;
+			UNLINK(cur, iflist, prev);
 			break;
 		}
 	}



More information about the asterisk-commits mailing list