Module: kamailio
Branch: master
Commit: 4df92312166d8aad700007ef0898d0a7c6ba40b7
URL: 
https://github.com/kamailio/kamailio/commit/4df92312166d8aad700007ef0898d0a7c6ba40b7

Author: Xenofon Karamanos <x...@gilawa.com>
Committer: Henning Westerholt <h...@gilawa.com>
Date: 2024-01-08T15:55:43+01:00

parser/contact: Change addition order to the end of list

- Contacts are now added at the end of the list.
- hfl(Contact)[index] is now returning in the correct order.

---

Modified: src/core/parser/contact/contact.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/4df92312166d8aad700007ef0898d0a7c6ba40b7.diff
Patch: 
https://github.com/kamailio/kamailio/commit/4df92312166d8aad700007ef0898d0a7c6ba40b7.patch

---

diff --git a/src/core/parser/contact/contact.c 
b/src/core/parser/contact/contact.c
index 3c66a2082b0..dd522a6cd3c 100644
--- a/src/core/parser/contact/contact.c
+++ b/src/core/parser/contact/contact.c
@@ -208,6 +208,18 @@ static inline int skip_name(str *_s)
        return -1;
 }
 
+static inline void contact_append(contact_t **head, contact_t *node)
+{
+       contact_t *ptr = *head;
+       if(*head == NULL) {
+               *head = node;
+               return;
+       }
+       while(ptr->next != NULL) {
+               ptr = ptr->next;
+       }
+       ptr->next = node;
+}
 
 /*
  * Parse contacts in a Contact HF
@@ -298,8 +310,7 @@ int parse_contacts(str *_s, contact_t **_c)
                _s->len--;
                trim_leading(_s);
 
-               c->next = *_c;
-               *_c = c;
+               contact_append(_c, c);
                c = NULL;
 
                if(_s->len == 0) {
@@ -318,8 +329,8 @@ int parse_contacts(str *_s, contact_t **_c)
 
 ok:
        c->len = _s->s - c->name.s;
-       c->next = *_c;
-       *_c = c;
+       contact_append(_c, c);
+       c = NULL;
        return 0;
 }
 

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

Reply via email to