Browse code

parser: use wrapper functions to reset fields in sip_msg_t

- used for freeing the structure

Daniel-Constantin Mierla authored on 19/09/2013 11:23:53
Showing 2 changed files
... ...
@@ -723,9 +723,12 @@ void free_reply_lump( struct lump_rpl *lump)
723 723
 /*only the content*/
724 724
 void free_sip_msg(struct sip_msg* const msg)
725 725
 {
726
-	if (msg->new_uri.s) { pkg_free(msg->new_uri.s); msg->new_uri.len=0; }
727
-	if (msg->dst_uri.s) { pkg_free(msg->dst_uri.s); msg->dst_uri.len=0; }
728
-	if (msg->path_vec.s) { pkg_free(msg->path_vec.s); msg->path_vec.len=0; }
726
+	reset_new_uri(msg);
727
+	reset_dst_uri(msg);
728
+	reset_path_vector(msg);
729
+	reset_instance(msg);
730
+	reset_ruid(msg);
731
+	reset_ua(msg);
729 732
 	if (msg->headers)     free_hdr_field_lst(msg->headers);
730 733
 	if (msg->body && msg->body->free) msg->body->free(&msg->body);
731 734
 	if (msg->add_rm)      free_lump_list(msg->add_rm);
... ...
@@ -737,6 +740,19 @@ void free_sip_msg(struct sip_msg* const msg)
737 737
 #	endif
738 738
 }
739 739
 
740
+/**
741
+ * reset new uri value
742
+ */
743
+void reset_new_uri(struct sip_msg* const msg)
744
+{
745
+	if(msg->new_uri.s != 0) {
746
+		pkg_free(msg->new_uri.s);
747
+	}
748
+	msg->new_uri.s = 0;
749
+	msg->new_uri.len = 0;
750
+	msg->parsed_uri_ok = 0;
751
+}
752
+
740 753
 
741 754
 /*
742 755
  * Make a private copy of the string and assign it to dst_uri
... ...
@@ -432,6 +432,8 @@ inline static char* get_body(struct sip_msg* const msg)
432 432
 	return msg->unparsed + offset;
433 433
 }
434 434
 
435
+/*! \brief If the new_uri is set, then reset it */
436
+void reset_new_uri(struct sip_msg* const msg);
435 437
 
436 438
 /*! \brief
437 439
  * Make a private copy of the string and assign it to dst_uri