[sr-dev] git:master: parser: use wrapper functions to reset fields in sip_msg_t

Daniel-Constantin Mierla miconda at gmail.com
Thu Sep 19 13:28:08 CEST 2013


Module: sip-router
Branch: master
Commit: cae9659766c84e9451e4ea41e61bf85337c89693
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=cae9659766c84e9451e4ea41e61bf85337c89693

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Thu Sep 19 13:23:53 2013 +0200

parser: use wrapper functions to reset fields in sip_msg_t

- used for freeing the structure

---

 parser/msg_parser.c |   22 +++++++++++++++++++---
 parser/msg_parser.h |    2 ++
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/parser/msg_parser.c b/parser/msg_parser.c
index d8709e4..02ad583 100644
--- a/parser/msg_parser.c
+++ b/parser/msg_parser.c
@@ -723,9 +723,12 @@ void free_reply_lump( struct lump_rpl *lump)
 /*only the content*/
 void free_sip_msg(struct sip_msg* const msg)
 {
-	if (msg->new_uri.s) { pkg_free(msg->new_uri.s); msg->new_uri.len=0; }
-	if (msg->dst_uri.s) { pkg_free(msg->dst_uri.s); msg->dst_uri.len=0; }
-	if (msg->path_vec.s) { pkg_free(msg->path_vec.s); msg->path_vec.len=0; }
+	reset_new_uri(msg);
+	reset_dst_uri(msg);
+	reset_path_vector(msg);
+	reset_instance(msg);
+	reset_ruid(msg);
+	reset_ua(msg);
 	if (msg->headers)     free_hdr_field_lst(msg->headers);
 	if (msg->body && msg->body->free) msg->body->free(&msg->body);
 	if (msg->add_rm)      free_lump_list(msg->add_rm);
@@ -737,6 +740,19 @@ void free_sip_msg(struct sip_msg* const msg)
 #	endif
 }
 
+/**
+ * reset new uri value
+ */
+void reset_new_uri(struct sip_msg* const msg)
+{
+	if(msg->new_uri.s != 0) {
+		pkg_free(msg->new_uri.s);
+	}
+	msg->new_uri.s = 0;
+	msg->new_uri.len = 0;
+	msg->parsed_uri_ok = 0;
+}
+
 
 /*
  * Make a private copy of the string and assign it to dst_uri
diff --git a/parser/msg_parser.h b/parser/msg_parser.h
index 5a618c6..5d481e0 100644
--- a/parser/msg_parser.h
+++ b/parser/msg_parser.h
@@ -432,6 +432,8 @@ inline static char* get_body(struct sip_msg* const msg)
 	return msg->unparsed + offset;
 }
 
+/*! \brief If the new_uri is set, then reset it */
+void reset_new_uri(struct sip_msg* const msg);
 
 /*! \brief
  * Make a private copy of the string and assign it to dst_uri




More information about the sr-dev mailing list