Index: pjproject/trunk/pjsip/src/pjsip/sip_msg.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_msg.c	(revision 51)
+++ pjproject/trunk/pjsip/src/pjsip/sip_msg.c	(revision 65)
@@ -869,4 +869,5 @@
     init_hdr(hdr, PJSIP_H_CONTACT, &contact_hdr_vptr);
     hdr->expires = -1;
+    pj_list_init(&hdr->other_param);
     return hdr;
 }
@@ -884,5 +885,4 @@
 	*p++ = ' ';
 	*p++ = '*';
-	*p = '\0';
 	return p - buf;
 
@@ -928,15 +928,15 @@
 	}
 
-	if (hdr->other_param.slen) {
-	    copy_advance(buf, hdr->other_param);
-	}
-
-	*buf = '\0';
+	printed = pjsip_param_print_on(&hdr->other_param, buf, endbuf-buf,';');
+	if (printed < 0)
+	    return printed;
+	buf += printed;
+
 	return buf-startbuf;
     }
 }
 
-static pjsip_contact_hdr* pjsip_contact_hdr_clone( pj_pool_t *pool, 
-					           const pjsip_contact_hdr *rhs)
+static pjsip_contact_hdr* pjsip_contact_hdr_clone(pj_pool_t *pool, 
+					          const pjsip_contact_hdr *rhs)
 {
     pjsip_contact_hdr *hdr = pjsip_contact_hdr_create(pool);
@@ -949,13 +949,15 @@
     hdr->q1000 = rhs->q1000;
     hdr->expires = rhs->expires;
-    pj_strdup(pool, &hdr->other_param, &rhs->other_param);
-    return hdr;
-}
-
-static pjsip_contact_hdr* pjsip_contact_hdr_shallow_clone( pj_pool_t *pool,
-							   const pjsip_contact_hdr *rhs)
+    pjsip_param_clone(pool, &hdr->other_param, &rhs->other_param);
+    return hdr;
+}
+
+static pjsip_contact_hdr* 
+pjsip_contact_hdr_shallow_clone( pj_pool_t *pool,
+				 const pjsip_contact_hdr *rhs)
 {
     pjsip_contact_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
     pj_memcpy(hdr, rhs, sizeof(*hdr));
+    pjsip_param_shallow_clone(pool, &hdr->other_param, &rhs->other_param);
     return hdr;
 }
@@ -965,6 +967,8 @@
  * Content-Type header..
  */
-static int pjsip_ctype_hdr_print( pjsip_ctype_hdr *hdr, char *buf, pj_size_t size);
-static pjsip_ctype_hdr* pjsip_ctype_hdr_clone( pj_pool_t *pool, const pjsip_ctype_hdr *hdr);
+static int pjsip_ctype_hdr_print( pjsip_ctype_hdr *hdr, char *buf, 
+				  pj_size_t size);
+static pjsip_ctype_hdr* pjsip_ctype_hdr_clone(pj_pool_t *pool, 
+					      const pjsip_ctype_hdr *hdr);
 #define pjsip_ctype_hdr_shallow_clone pjsip_ctype_hdr_clone
 
@@ -1071,4 +1075,5 @@
     pjsip_from_hdr *hdr = pj_pool_calloc(pool, 1, sizeof(*hdr));
     init_hdr(hdr, PJSIP_H_FROM, &fromto_hdr_vptr);
+    pj_list_init(&hdr->other_param);
     return hdr;
 }
@@ -1078,4 +1083,5 @@
     pjsip_to_hdr *hdr = pj_pool_calloc(pool, 1, sizeof(*hdr));
     init_hdr(hdr, PJSIP_H_TO, &fromto_hdr_vptr);
+    pj_list_init(&hdr->other_param);
     return hdr;
 }
@@ -1106,5 +1112,6 @@
     *buf++ = ' ';
 
-    printed = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, hdr->uri, buf, endbuf-buf);
+    printed = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, hdr->uri, 
+			      buf, endbuf-buf);
     if (printed < 1)
 	return -1;
@@ -1113,6 +1120,9 @@
 
     copy_advance_pair(buf, ";tag=", 5, hdr->tag);
-    if (hdr->other_param.slen)
-	copy_advance(buf, hdr->other_param);
+
+    printed = pjsip_param_print_on(&hdr->other_param, buf, endbuf-buf, ';');
+    if (printed < 0)
+	return -1;
+    buf += printed;
 
     return buf-startbuf;
@@ -1129,14 +1139,16 @@
     hdr->uri = pjsip_uri_clone(pool, rhs->uri);
     pj_strdup( pool, &hdr->tag, &rhs->tag);
-    pj_strdup( pool, &hdr->other_param, &rhs->other_param);
-
-    return hdr;
-}
-
-static pjsip_fromto_hdr* pjsip_fromto_hdr_shallow_clone( pj_pool_t *pool,
-							 const pjsip_fromto_hdr *rhs)
+    pjsip_param_clone( pool, &hdr->other_param, &rhs->other_param);
+
+    return hdr;
+}
+
+static pjsip_fromto_hdr* 
+pjsip_fromto_hdr_shallow_clone( pj_pool_t *pool,
+				const pjsip_fromto_hdr *rhs)
 {
     pjsip_fromto_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
     pj_memcpy(hdr, rhs, sizeof(*hdr));
+    pjsip_param_shallow_clone( pool, &hdr->other_param, &rhs->other_param);
     return hdr;
 }
@@ -1188,5 +1200,5 @@
     init_hdr(hdr, PJSIP_H_RECORD_ROUTE, &routing_hdr_vptr);
     pjsip_name_addr_init(&hdr->name_addr);
-    pj_memset(&hdr->other_param, 0, sizeof(hdr->other_param));
+    pj_list_init(&hdr->other_param);
     return hdr;
 }
@@ -1197,5 +1209,5 @@
     init_hdr(hdr, PJSIP_H_ROUTE, &routing_hdr_vptr);
     pjsip_name_addr_init(&hdr->name_addr);
-    pj_memset(&hdr->other_param, 0, sizeof(hdr->other_param));
+    pj_list_init(&hdr->other_param);
     return hdr;
 }
@@ -1226,12 +1238,14 @@
     *buf++ = ' ';
 
-    printed = pjsip_uri_print(PJSIP_URI_IN_ROUTING_HDR, &hdr->name_addr, buf, endbuf-buf);
+    printed = pjsip_uri_print(PJSIP_URI_IN_ROUTING_HDR, &hdr->name_addr, buf, 
+			      endbuf-buf);
     if (printed < 1)
 	return -1;
     buf += printed;
 
-    if (hdr->other_param.slen) {
-	copy_advance(buf, hdr->other_param);
-    }
+    printed = pjsip_param_print_on(&hdr->other_param, buf, endbuf-buf, ';');
+    if (printed < 0)
+	return -1;
+    buf += printed;
 
     return buf-startbuf;
@@ -1246,5 +1260,5 @@
     pjsip_name_addr_init(&hdr->name_addr);
     pjsip_name_addr_assign(pool, &hdr->name_addr, &rhs->name_addr);
-    pj_strdup( pool, &hdr->other_param, &rhs->other_param);
+    pjsip_param_clone( pool, &hdr->other_param, &rhs->other_param);
     return hdr;
 }
@@ -1255,4 +1269,5 @@
     pjsip_routing_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
     pj_memcpy(hdr, rhs, sizeof(*hdr));
+    pjsip_param_shallow_clone( pool, &hdr->other_param, &rhs->other_param);
     return hdr;
 }
@@ -1331,4 +1346,5 @@
     hdr->ttl_param = -1;
     hdr->rport_param = -1;
+    pj_list_init(&hdr->other_param);
     return hdr;
 }
@@ -1390,7 +1406,10 @@
     copy_advance_pair(buf, ";received=", 10, hdr->recvd_param);
     copy_advance_pair(buf, ";branch=", 8, hdr->branch_param);
-    copy_advance(buf, hdr->other_param);
     
-    *buf = '\0';
+    printed = pjsip_param_print_on(&hdr->other_param, buf, endbuf-buf, ';');
+    if (printed < 0)
+	return -1;
+    buf += printed;
+    
     return buf-startbuf;
 }
@@ -1408,5 +1427,5 @@
     pj_strdup(pool, &hdr->recvd_param, &rhs->recvd_param);
     pj_strdup(pool, &hdr->branch_param, &rhs->branch_param);
-    pj_strdup(pool, &hdr->other_param, &rhs->other_param);
+    pjsip_param_clone(pool, &hdr->other_param, &rhs->other_param);
     return hdr;
 }
@@ -1417,4 +1436,5 @@
     pjsip_via_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
     pj_memcpy(hdr, rhs, sizeof(*hdr));
+    pjsip_param_shallow_clone(pool, &hdr->other_param, &rhs->other_param);
     return hdr;
 }
