Module: kamailio
Branch: master
Commit: 41cfe077c283c54a026e3df9658e832e72a8fdf3
URL: 
https://github.com/kamailio/kamailio/commit/41cfe077c283c54a026e3df9658e832e72a8fdf3

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-01-20T11:31:51+01:00

core: function to copy reply lump list

---

Modified: src/core/data_lump_rpl.c
Modified: src/core/data_lump_rpl.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/41cfe077c283c54a026e3df9658e832e72a8fdf3.diff
Patch: 
https://github.com/kamailio/kamailio/commit/41cfe077c283c54a026e3df9658e832e72a8fdf3.patch

---

diff --git a/src/core/data_lump_rpl.c b/src/core/data_lump_rpl.c
index d1991a3c943..e3b322f97d8 100644
--- a/src/core/data_lump_rpl.c
+++ b/src/core/data_lump_rpl.c
@@ -125,6 +125,43 @@ void free_reply_lump_list(struct lump_rpl *lump)
 }
 
 
+struct lump_rpl *copy_reply_lump_list(struct lump_rpl *lump_list)
+{
+       struct lump_rpl *nlump;
+       struct lump_rpl *flump;
+       struct lump_rpl *llump;
+       struct lump_rpl *clump;
+
+       flump = NULL;
+       for(clump = lump_list; clump; clump = clump->next) {
+               nlump = (struct lump_rpl *)pkg_malloc(
+                               sizeof(struct lump_rpl) + clump->text.len + 1);
+               if(nlump == NULL) {
+                       PKG_MEM_ERROR;
+                       goto error;
+               }
+               memset(nlump, 0, sizeof(struct lump_rpl));
+               nlump->text.s = ((char *)nlump) + sizeof(struct lump_rpl);
+               memcpy(nlump->text.s, clump->text.s, clump->text.len);
+               nlump->text.len = clump->text.len;
+               nlump->text.s[nlump->text.len] = '\0';
+               nlump->flags = clump->flags & (LUMP_RPL_HDR | LUMP_RPL_BODY);
+               nlump->next = NULL;
+               if(flump == NULL) {
+                       flump = nlump;
+               }
+               if(llump != NULL) {
+                       llump->next = nlump;
+               }
+               llump = clump;
+       }
+       return flump;
+
+error:
+       free_reply_lump_list(flump);
+       return NULL;
+}
+
 void unlink_lump_rpl(struct sip_msg *msg, struct lump_rpl *lump)
 {
        struct lump_rpl *foo, *prev;
diff --git a/src/core/data_lump_rpl.h b/src/core/data_lump_rpl.h
index 8a4d289d3a4..669bd72a52b 100644
--- a/src/core/data_lump_rpl.h
+++ b/src/core/data_lump_rpl.h
@@ -66,6 +66,8 @@ inline static struct lump_rpl *add_lump_rpl(
 void free_lump_rpl(struct lump_rpl *);
 void free_reply_lump_list(struct lump_rpl *lump);
 
+struct lump_rpl *copy_reply_lump_list(struct lump_rpl *lump);
+
 void unlink_lump_rpl(struct sip_msg *, struct lump_rpl *);
 
 void del_nonshm_lump_rpl(struct lump_rpl **);

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to