[sr-dev] git:master: parser: some more const-correctness for the other functions in msg_parser.[c, h]

Henning Westerholt hw at kamailio.org
Thu Jul 5 23:16:10 CEST 2012


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

Author: Henning Westerholt <hw at kamailio.org>
Committer: Henning Westerholt <hw at kamailio.org>
Date:   Thu Jul  5 23:04:43 2012 +0200

parser: some more const-correctness for the other functions in msg_parser.[c,h]

---

 parser/msg_parser.c |   16 ++++++++--------
 parser/msg_parser.h |   20 ++++++++++----------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/parser/msg_parser.c b/parser/msg_parser.c
index d8247ec..986c8e0 100644
--- a/parser/msg_parser.c
+++ b/parser/msg_parser.c
@@ -316,7 +316,7 @@ error:
    give you the first occurrence of a header you are interested in,
    look at check_transaction_quadruple
 */
-int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next)
+int parse_headers(struct sip_msg* const msg, const hdr_flags_t flags, const int next)
 {
 	struct hdr_field* hf;
 	char* tmp;
@@ -595,7 +595,7 @@ error:
 
 
 /* returns 0 if ok, -1 for errors */
-int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
+int parse_msg(char* const buf, const unsigned int len, struct sip_msg* const msg)
 {
 
 	char *tmp;
@@ -719,7 +719,7 @@ void free_reply_lump( struct lump_rpl *lump)
 
 
 /*only the content*/
-void free_sip_msg(struct sip_msg* msg)
+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; }
@@ -739,7 +739,7 @@ void free_sip_msg(struct sip_msg* msg)
 /*
  * Make a private copy of the string and assign it to dst_uri
  */
-int set_dst_uri(struct sip_msg* msg, str* uri)
+int set_dst_uri(struct sip_msg* const msg, const str* const uri)
 {
 	char* ptr;
 
@@ -769,7 +769,7 @@ int set_dst_uri(struct sip_msg* msg, str* uri)
 }
 
 
-void reset_dst_uri(struct sip_msg* msg)
+void reset_dst_uri(struct sip_msg* const msg)
 {
 	if(msg->dst_uri.s != 0) {
 		pkg_free(msg->dst_uri.s);
@@ -869,7 +869,7 @@ hdr_field_t* next_sibling_hdr_by_name(hdr_field_t *hf)
  * set msg context id
  * - return: -1 on error; 0 - on set
  */
-int msg_ctx_id_set(sip_msg_t *msg, msg_ctx_id_t *mid)
+int msg_ctx_id_set(const sip_msg_t* const msg, msg_ctx_id_t* const mid)
 {
 	if(msg==NULL || mid==NULL)
 		return -1;
@@ -882,7 +882,7 @@ int msg_ctx_id_set(sip_msg_t *msg, msg_ctx_id_t *mid)
  * check msg context id
  * - return: -1 on error; 0 - on no match; 1 - on match
  */
-int msg_ctx_id_match(sip_msg_t *msg, msg_ctx_id_t *mid)
+int msg_ctx_id_match(const sip_msg_t* const msg, const msg_ctx_id_t* const mid)
 {
 	if(msg==NULL || mid==NULL)
 		return -1;
@@ -894,7 +894,7 @@ int msg_ctx_id_match(sip_msg_t *msg, msg_ctx_id_t *mid)
 /**
  * set msg time value
  */
-int msg_set_time(sip_msg_t *msg)
+int msg_set_time(sip_msg_t* const msg)
 {
 	if(unlikely(msg==NULL))
 		return -2;
diff --git a/parser/msg_parser.h b/parser/msg_parser.h
index d16fa24..bc9a551 100644
--- a/parser/msg_parser.h
+++ b/parser/msg_parser.h
@@ -382,18 +382,18 @@ extern int via_cnt;
 extern unsigned int global_req_flags;
 
 
-int parse_msg(char* buf, unsigned int len, struct sip_msg* msg);
+int parse_msg(char* const buf, const unsigned int len, struct sip_msg* const msg);
 
-int parse_headers(struct sip_msg* msg, hdr_flags_t flags, int next);
+int parse_headers(struct sip_msg* const msg, const hdr_flags_t flags, const int next);
 
 char* get_hdr_field(char* const buf, char* const end, struct hdr_field* const hdr);
 
-void free_sip_msg(struct sip_msg* msg);
+void free_sip_msg(struct sip_msg* const msg);
 
 /*! \brief make sure all HFs needed for transaction identification have been
    parsed; return 0 if those HFs can't be found
 */
-inline static int check_transaction_quadruple( struct sip_msg* msg )
+inline static int check_transaction_quadruple(struct sip_msg* const msg)
 {
 	if ( parse_headers(msg, HDR_FROM_F|HDR_TO_F|HDR_CALLID_F|HDR_CSEQ_F,0)!=-1
 		&& msg->from && msg->to && msg->callid && msg->cseq ) {
@@ -408,7 +408,7 @@ inline static int check_transaction_quadruple( struct sip_msg* msg )
 
 /*! \brief returns a pointer to the begining of the msg's body
  */
-inline static char* get_body(struct sip_msg *msg)
+inline static char* get_body(struct sip_msg* const msg)
 {
 	int offset;
 	unsigned int len;
@@ -434,10 +434,10 @@ inline static char* get_body(struct sip_msg *msg)
 /*! \brief
  * Make a private copy of the string and assign it to dst_uri
  */
-int set_dst_uri(struct sip_msg* msg, str* uri);
+int set_dst_uri(struct sip_msg* const msg, const str* const uri);
 
 /*! \brief If the dst_uri is set to an URI then reset it */
-void reset_dst_uri(struct sip_msg* msg);
+void reset_dst_uri(struct sip_msg* const msg);
 
 hdr_field_t* get_hdr(sip_msg_t *msg, enum _hdr_types_t ht);
 hdr_field_t* next_sibling_hdr(hdr_field_t *hf);
@@ -479,17 +479,17 @@ typedef struct msg_ctx_id {
  * set msg context id
  * - return: -1 on error; 0 - on set 
  */
-int msg_ctx_id_set(sip_msg_t *msg, msg_ctx_id_t *mid);
+int msg_ctx_id_set(const sip_msg_t* const msg, msg_ctx_id_t* const mid);
 
 /**
  * check msg context id
  * - return: -1 on error; 0 - on no match; 1 - on match
  */
-int msg_ctx_id_match(sip_msg_t *msg, msg_ctx_id_t *mid);
+int msg_ctx_id_match(const sip_msg_t* const msg, const msg_ctx_id_t* const mid);
 
 /**
  * set msg time value
  */
-int msg_set_time(sip_msg_t *msg);
+int msg_set_time(sip_msg_t* const msg);
 
 #endif




More information about the sr-dev mailing list