[Pkg-voip-commits] [bctoolbox] 16/57: Improve bctbx_freeaddrinfo() algorithm.

daniel at gnoutcheff.name daniel at gnoutcheff.name
Thu Mar 30 04:31:31 UTC 2017


This is an automated email from the git hooks/post-receive script.

gnoutchd-guest pushed a commit to branch debian/sid
in repository bctoolbox.

commit 02208ed78490216d18a989cfe97861434a56fb4d
Author: Ghislain MARY <ghislain.mary at belledonne-communications.com>
Date:   Tue Nov 29 18:01:34 2016 +0100

    Improve bctbx_freeaddrinfo() algorithm.
---
 src/utils/port.c | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/src/utils/port.c b/src/utils/port.c
index 0c14438..209995e 100644
--- a/src/utils/port.c
+++ b/src/utils/port.c
@@ -1407,18 +1407,30 @@ void _bctbx_freeaddrinfo(struct addrinfo *res){
 }
 
 void bctbx_freeaddrinfo(struct addrinfo *res){
-	struct addrinfo *it,*previt=NULL;
-	struct addrinfo *allocated_by_bctbx=NULL;
-	
-	for(it=res;it!=NULL;it=it->ai_next){
-		if (it->ai_canonname ==  allocated_by_bctbx_magic){
-			allocated_by_bctbx=it;
-			if (previt) previt->ai_next=NULL;
-			break;
+	struct addrinfo *it;
+	struct addrinfo *previt = NULL;
+	struct addrinfo *beginit = res;
+	bool_t looking_for_allocated_by_bctbx = (res->ai_canonname == allocated_by_bctbx_magic) ? TRUE : FALSE;
+
+	for (it = res; it != NULL; it = it->ai_next) {
+		if ((looking_for_allocated_by_bctbx == TRUE) && (it->ai_canonname != allocated_by_bctbx_magic)) {
+			if (previt) {
+				previt->ai_next = NULL;
+				_bctbx_freeaddrinfo(beginit);
+				looking_for_allocated_by_bctbx = FALSE;
+				beginit = it;
+			}
+		} else if ((looking_for_allocated_by_bctbx == FALSE) && (it->ai_canonname == allocated_by_bctbx_magic)) {
+			if (previt) {
+				previt->ai_next = NULL;
+				freeaddrinfo(beginit);
+				looking_for_allocated_by_bctbx = TRUE;
+				beginit = it;
+			}
 		}
-		previt=it;
+		previt = it;
 	}
-	if (res!=allocated_by_bctbx) freeaddrinfo(res);
-	if (allocated_by_bctbx) _bctbx_freeaddrinfo(allocated_by_bctbx);
+	if (looking_for_allocated_by_bctbx == TRUE) _bctbx_freeaddrinfo(beginit);
+	else freeaddrinfo(beginit);
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/bctoolbox.git



More information about the Pkg-voip-commits mailing list