Module: kamailio
Branch: master
Commit: f8f40045e1370002076f568a1e73e0b4b67e9d66
URL:
https://github.com/kamailio/kamailio/commit/f8f40045e1370002076f568a1e73e0b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-06-05T11:42:06+02:00
core: resolve negative index for dset before checking if it is last branch
- faster dropping of last branch
---
Modified: dset.c
---
Diff:
https://github.com/kamailio/kamailio/commit/f8f40045e1370002076f568a1e73e0b…
Patch:
https://github.com/kamailio/kamailio/commit/f8f40045e1370002076f568a1e73e0b…
---
diff --git a/dset.c b/dset.c
index 2fb3b70..46cc40d 100644
--- a/dset.c
+++ b/dset.c
@@ -122,14 +122,14 @@ int drop_sip_branch(int idx)
return 0;
if(idx<0 && (int)nr_branches+idx<0)
return 0;
+ if(idx<0)
+ idx += nr_branches;
/* last branch */
if(idx==nr_branches-1)
{
nr_branches--;
return 0;
}
- if(idx<0)
- idx = nr_branches+idx;
/* shift back one position */
for(; idx<nr_branches-1; idx++)
memcpy(&branches[idx], &branches[idx+1], sizeof(branch_t));