Browse Source

parser: use wrapper functions to reset fields in sip_msg_t

- used for freeing the structure
Daniel-Constantin Mierla 12 years ago
parent
commit
cae9659766
2 changed files with 21 additions and 3 deletions
  1. 19 3
      parser/msg_parser.c
  2. 2 0
      parser/msg_parser.h

+ 19 - 3
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

+ 2 - 0
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