Index: pjproject/trunk/pjsip/src/pjsip/sip_msg.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip/sip_msg.c	(revision 119)
+++ pjproject/trunk/pjsip/src/pjsip/sip_msg.c	(revision 127)
@@ -499,8 +499,12 @@
 };
 
-PJ_DEF(pjsip_generic_string_hdr*) pjsip_generic_string_hdr_create( pj_pool_t *pool,
-						     const pj_str_t *hnames )
-{
-    pjsip_generic_string_hdr *hdr = pj_pool_alloc(pool, sizeof(pjsip_generic_string_hdr));
+PJ_DEF(pjsip_generic_string_hdr*) 
+pjsip_generic_string_hdr_init( pj_pool_t *pool,
+			       void *mem,
+			       const pj_str_t *hnames,
+			       const pj_str_t *hvalue)
+{
+    pjsip_generic_string_hdr *hdr = mem;
+
     init_hdr(hdr, PJSIP_H_OTHER, &generic_hdr_vptr);
     if (hnames) {
@@ -508,20 +512,25 @@
 	hdr->sname = hdr->name;
     }
-    hdr->hvalue.ptr = NULL;
-    hdr->hvalue.slen = 0;
-    return hdr;
-}
-
-PJ_DEF(pjsip_generic_string_hdr*) pjsip_generic_string_hdr_create_with_text( pj_pool_t *pool,
-							       const pj_str_t *hname,
-							       const pj_str_t *hvalue)
-{
-    pjsip_generic_string_hdr *hdr = pjsip_generic_string_hdr_create(pool, hname);
-    pj_strdup(pool, &hdr->hvalue, hvalue);
-    return hdr;
-}
-
-static int pjsip_generic_string_hdr_print( pjsip_generic_string_hdr *hdr, 
-				    char *buf, pj_size_t size)
+    if (hvalue) {
+	pj_strdup(pool, &hdr->hvalue, hvalue);
+    } else {
+	hdr->hvalue.ptr = NULL;
+	hdr->hvalue.slen = 0;
+    }
+
+    return hdr;
+}
+
+PJ_DEF(pjsip_generic_string_hdr*) 
+pjsip_generic_string_hdr_create( pj_pool_t *pool,
+				 const pj_str_t *hnames,
+				 const pj_str_t *hvalue)
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_generic_string_hdr));
+    return pjsip_generic_string_hdr_init(pool, mem, hnames, hvalue);
+}
+
+static int pjsip_generic_string_hdr_print( pjsip_generic_string_hdr *hdr,
+					   char *buf, pj_size_t size)
 {
     char *p = buf;
@@ -544,9 +553,10 @@
 					           const pjsip_generic_string_hdr *rhs)
 {
-    pjsip_generic_string_hdr *hdr = pjsip_generic_string_hdr_create(pool, &rhs->name);
+    pjsip_generic_string_hdr *hdr;
+    
+    hdr = pjsip_generic_string_hdr_create(pool, &rhs->name, &rhs->hvalue);
 
     hdr->type = rhs->type;
     hdr->sname = hdr->name;
-    pj_strdup( pool, &hdr->hvalue, &rhs->hvalue);
     return hdr;
 }
@@ -579,8 +589,11 @@
 };
 
-PJ_DEF(pjsip_generic_int_hdr*) pjsip_generic_int_hdr_create( pj_pool_t *pool,
-						     const pj_str_t *hnames )
-{
-    pjsip_generic_int_hdr *hdr = pj_pool_alloc(pool, sizeof(pjsip_generic_int_hdr));
+PJ_DEF(pjsip_generic_int_hdr*) pjsip_generic_int_hdr_init(  pj_pool_t *pool,
+							    void *mem,
+							    const pj_str_t *hnames,
+							    int value)
+{
+    pjsip_generic_int_hdr *hdr = mem;
+
     init_hdr(hdr, PJSIP_H_OTHER, &generic_int_hdr_vptr);
     if (hnames) {
@@ -588,15 +601,14 @@
 	hdr->sname = hdr->name;
     }
-    hdr->ivalue = 0;
-    return hdr;
-}
-
-PJ_DEF(pjsip_generic_int_hdr*) pjsip_generic_int_hdr_create_with_value( pj_pool_t *pool,
-							       const pj_str_t *hname,
-							       int value)
-{
-    pjsip_generic_int_hdr *hdr = pjsip_generic_int_hdr_create(pool, hname);
     hdr->ivalue = value;
     return hdr;
+}
+
+PJ_DEF(pjsip_generic_int_hdr*) pjsip_generic_int_hdr_create( pj_pool_t *pool,
+						     const pj_str_t *hnames,
+						     int value)
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_generic_int_hdr));
+    return pjsip_generic_int_hdr_init(pool, mem, hnames, value);
 }
 
@@ -652,8 +664,11 @@
 };
 
-PJ_DEF(pjsip_generic_array_hdr*) pjsip_generic_array_create( pj_pool_t *pool,
-							     const pj_str_t *hnames)
-{
-    pjsip_generic_array_hdr *hdr = pj_pool_alloc(pool, sizeof(pjsip_generic_array_hdr));
+
+PJ_DEF(pjsip_generic_array_hdr*) pjsip_generic_array_hdr_init( pj_pool_t *pool,
+							       void *mem,
+							       const pj_str_t *hnames)
+{
+    pjsip_generic_array_hdr *hdr = mem;
+
     init_hdr(hdr, PJSIP_H_OTHER, &generic_array_hdr_vptr);
     if (hnames) {
@@ -663,4 +678,11 @@
     hdr->count = 0;
     return hdr;
+}
+
+PJ_DEF(pjsip_generic_array_hdr*) pjsip_generic_array_hdr_create( pj_pool_t *pool,
+							     const pj_str_t *hnames)
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_generic_array_hdr));
+    return pjsip_generic_array_hdr_init(pool, mem, hnames);
 
 }
@@ -714,7 +736,11 @@
  * Accept header.
  */
-PJ_DEF(pjsip_accept_hdr*) pjsip_accept_hdr_create(pj_pool_t *pool)
-{
-    pjsip_accept_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
+PJ_DEF(pjsip_accept_hdr*) pjsip_accept_hdr_init( pj_pool_t *pool,
+						 void *mem )
+{
+    pjsip_accept_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
     init_hdr(hdr, PJSIP_H_ACCEPT, &generic_array_hdr_vptr);
     hdr->count = 0;
@@ -722,4 +748,10 @@
 }
 
+PJ_DEF(pjsip_accept_hdr*) pjsip_accept_hdr_create(pj_pool_t *pool)
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_accept_hdr));
+    return pjsip_accept_hdr_init(pool, mem);
+}
+
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -728,7 +760,11 @@
  */
 
-PJ_DEF(pjsip_allow_hdr*) pjsip_allow_hdr_create(pj_pool_t *pool)
-{
-    pjsip_allow_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
+PJ_DEF(pjsip_allow_hdr*) pjsip_allow_hdr_init( pj_pool_t *pool,
+					       void *mem )
+{
+    pjsip_allow_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
     init_hdr(hdr, PJSIP_H_ALLOW, &generic_array_hdr_vptr);
     hdr->count = 0;
@@ -736,4 +772,10 @@
 }
 
+PJ_DEF(pjsip_allow_hdr*) pjsip_allow_hdr_create(pj_pool_t *pool)
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_allow_hdr));
+    return pjsip_allow_hdr_init(pool, mem);
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 /*
@@ -741,9 +783,20 @@
  */
 
+PJ_DEF(pjsip_cid_hdr*) pjsip_cid_hdr_init( pj_pool_t *pool,
+					   void *mem )
+{
+    pjsip_cid_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
+    init_hdr(hdr, PJSIP_H_CALL_ID, &generic_hdr_vptr);
+    return hdr;
+
+}
+
 PJ_DEF(pjsip_cid_hdr*) pjsip_cid_hdr_create( pj_pool_t *pool )
 {
-    pjsip_cid_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
-    init_hdr(hdr, PJSIP_H_CALL_ID, &generic_hdr_vptr);
-    return hdr;
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_cid_hdr));
+    return pjsip_cid_hdr_init(pool, mem);
 }
 
@@ -764,10 +817,20 @@
 };
 
-PJ_DEF(pjsip_clen_hdr*) pjsip_clen_hdr_create( pj_pool_t *pool )
-{
-    pjsip_clen_hdr *hdr = pj_pool_alloc(pool, sizeof(pjsip_clen_hdr));
+PJ_DEF(pjsip_clen_hdr*) pjsip_clen_hdr_init( pj_pool_t *pool,
+					     void *mem )
+{
+    pjsip_clen_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
     init_hdr(hdr, PJSIP_H_CONTENT_LENGTH, &clen_hdr_vptr);
     hdr->len = 0;
     return hdr;
+}
+
+PJ_DEF(pjsip_clen_hdr*) pjsip_clen_hdr_create( pj_pool_t *pool )
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_clen_hdr));
+    return pjsip_clen_hdr_init(pool, mem);
 }
 
@@ -816,7 +879,11 @@
 };
 
-PJ_DEF(pjsip_cseq_hdr*) pjsip_cseq_hdr_create( pj_pool_t *pool )
-{
-    pjsip_cseq_hdr *hdr = pj_pool_alloc(pool, sizeof(pjsip_cseq_hdr));
+PJ_DEF(pjsip_cseq_hdr*) pjsip_cseq_hdr_init( pj_pool_t *pool,
+					     void *mem )
+{
+    pjsip_cseq_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
     init_hdr(hdr, PJSIP_H_CSEQ, &cseq_hdr_vptr);
     hdr->cseq = 0;
@@ -827,4 +894,10 @@
 }
 
+PJ_DEF(pjsip_cseq_hdr*) pjsip_cseq_hdr_create( pj_pool_t *pool )
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_cseq_hdr));
+    return pjsip_cseq_hdr_init(pool, mem);
+}
+
 static int pjsip_cseq_hdr_print( pjsip_cseq_hdr *hdr, char *buf, pj_size_t size)
 {
@@ -885,11 +958,22 @@
 };
 
-PJ_DEF(pjsip_contact_hdr*) pjsip_contact_hdr_create( pj_pool_t *pool )
-{
-    pjsip_contact_hdr *hdr = pj_pool_calloc(pool, 1, sizeof(*hdr));
+PJ_DEF(pjsip_contact_hdr*) pjsip_contact_hdr_init( pj_pool_t *pool,
+						   void *mem )
+{
+    pjsip_contact_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
+    pj_memset(mem, 0, sizeof(pjsip_contact_hdr));
     init_hdr(hdr, PJSIP_H_CONTACT, &contact_hdr_vptr);
     hdr->expires = -1;
     pj_list_init(&hdr->other_param);
     return hdr;
+}
+
+PJ_DEF(pjsip_contact_hdr*) pjsip_contact_hdr_create( pj_pool_t *pool )
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_contact_hdr));
+    return pjsip_contact_hdr_init(pool, mem);
 }
 
@@ -1003,9 +1087,21 @@
 };
 
+PJ_DEF(pjsip_ctype_hdr*) pjsip_ctype_hdr_init( pj_pool_t *pool,
+					       void *mem )
+{
+    pjsip_ctype_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
+    pj_memset(mem, 0, sizeof(pjsip_ctype_hdr));
+    init_hdr(hdr, PJSIP_H_CONTENT_TYPE, &ctype_hdr_vptr);
+    return hdr;
+
+}
+
 PJ_DEF(pjsip_ctype_hdr*) pjsip_ctype_hdr_create( pj_pool_t *pool )
 {
-    pjsip_ctype_hdr *hdr = pj_pool_calloc(pool, 1, sizeof(*hdr));
-    init_hdr(hdr, PJSIP_H_CONTENT_TYPE, &ctype_hdr_vptr);
-    return hdr;
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_ctype_hdr));
+    return pjsip_ctype_hdr_init(pool, mem);
 }
 
@@ -1067,10 +1163,23 @@
  * Expires header.
  */
-PJ_DEF(pjsip_expires_hdr*) pjsip_expires_hdr_create( pj_pool_t *pool )
-{
-    pjsip_expires_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
+PJ_DEF(pjsip_expires_hdr*) pjsip_expires_hdr_init( pj_pool_t *pool,
+						   void *mem,
+						   int value)
+{
+    pjsip_expires_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
     init_hdr(hdr, PJSIP_H_EXPIRES, &generic_int_hdr_vptr);
-    hdr->ivalue = 0;
-    return hdr;
+    hdr->ivalue = value;
+    return hdr;
+
+}
+
+PJ_DEF(pjsip_expires_hdr*) pjsip_expires_hdr_create( pj_pool_t *pool,
+						     int value )
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_expires_hdr));
+    return pjsip_expires_hdr_init(pool, mem, value);
 }
 
@@ -1094,7 +1203,12 @@
 };
 
-PJ_DEF(pjsip_from_hdr*) pjsip_from_hdr_create( pj_pool_t *pool )
-{
-    pjsip_from_hdr *hdr = pj_pool_calloc(pool, 1, sizeof(*hdr));
+PJ_DEF(pjsip_from_hdr*) pjsip_from_hdr_init( pj_pool_t *pool,
+					     void *mem )
+{
+    pjsip_from_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
+    pj_memset(mem, 0, sizeof(pjsip_from_hdr));
     init_hdr(hdr, PJSIP_H_FROM, &fromto_hdr_vptr);
     pj_list_init(&hdr->other_param);
@@ -1102,13 +1216,31 @@
 }
 
-PJ_DEF(pjsip_to_hdr*) pjsip_to_hdr_create( pj_pool_t *pool )
-{
-    pjsip_to_hdr *hdr = pj_pool_calloc(pool, 1, sizeof(*hdr));
+PJ_DEF(pjsip_from_hdr*) pjsip_from_hdr_create( pj_pool_t *pool )
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_from_hdr));
+    return pjsip_from_hdr_init(pool, mem);
+}
+
+PJ_DEF(pjsip_to_hdr*) pjsip_to_hdr_init( pj_pool_t *pool,
+					 void *mem )
+{
+    pjsip_to_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
+    pj_memset(mem, 0, sizeof(pjsip_to_hdr));
     init_hdr(hdr, PJSIP_H_TO, &fromto_hdr_vptr);
     pj_list_init(&hdr->other_param);
     return hdr;
-}
-
-PJ_DEF(pjsip_from_hdr*) pjsip_fromto_set_from( pjsip_fromto_hdr *hdr )
+
+}
+
+PJ_DEF(pjsip_to_hdr*) pjsip_to_hdr_create( pj_pool_t *pool )
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_to_hdr));
+    return pjsip_to_hdr_init(pool, mem);
+}
+
+PJ_DEF(pjsip_from_hdr*) pjsip_fromto_hdr_set_from( pjsip_fromto_hdr *hdr )
 {
     hdr->type = PJSIP_H_FROM;
@@ -1117,5 +1249,5 @@
 }
 
-PJ_DEF(pjsip_to_hdr*) pjsip_fromto_set_to( pjsip_fromto_hdr *hdr )
+PJ_DEF(pjsip_to_hdr*) pjsip_fromto_hdr_set_to( pjsip_fromto_hdr *hdr )
 {
     hdr->type = PJSIP_H_TO;
@@ -1184,10 +1316,23 @@
  * Max-Forwards header.
  */
-PJ_DEF(pjsip_max_forwards_hdr*) pjsip_max_forwards_hdr_create(pj_pool_t *pool)
-{
-    pjsip_max_forwards_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
+PJ_DEF(pjsip_max_fwd_hdr*) pjsip_max_fwd_hdr_init( pj_pool_t *pool,
+						   void *mem,
+						   int value)
+{
+    pjsip_max_fwd_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
     init_hdr(hdr, PJSIP_H_MAX_FORWARDS, &generic_int_hdr_vptr);
-    hdr->ivalue = 0;
-    return hdr;
+    hdr->ivalue = value;
+    return hdr;
+
+}
+
+PJ_DEF(pjsip_max_fwd_hdr*) pjsip_max_fwd_hdr_create(pj_pool_t *pool,
+						    int value)
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_max_fwd_hdr));
+    return pjsip_max_fwd_hdr_init(pool, mem, value);
 }
 
@@ -1197,10 +1342,22 @@
  * Min-Expires header.
  */
-PJ_DECL(pjsip_min_expires_hdr*) pjsip_min_expires_hdr_create(pj_pool_t *pool)
-{
-    pjsip_min_expires_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
+PJ_DEF(pjsip_min_expires_hdr*) pjsip_min_expires_hdr_init( pj_pool_t *pool,
+							   void *mem,
+							   int value )
+{
+    pjsip_min_expires_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
     init_hdr(hdr, PJSIP_H_MIN_EXPIRES, &generic_int_hdr_vptr);
-    hdr->ivalue = 0;
-    return hdr;
+    hdr->ivalue = value;
+    return hdr;
+}
+
+PJ_DEF(pjsip_min_expires_hdr*) pjsip_min_expires_hdr_create(pj_pool_t *pool,
+							    int value )
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_min_expires_hdr));
+    return pjsip_min_expires_hdr_init(pool, mem, value );
 }
 
@@ -1220,20 +1377,41 @@
 };
 
-PJ_DEF(pjsip_rr_hdr*) pjsip_rr_hdr_create( pj_pool_t *pool )
-{
-    pjsip_rr_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
+PJ_DEF(pjsip_rr_hdr*) pjsip_rr_hdr_init( pj_pool_t *pool,
+					 void *mem )
+{
+    pjsip_rr_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
     init_hdr(hdr, PJSIP_H_RECORD_ROUTE, &routing_hdr_vptr);
     pjsip_name_addr_init(&hdr->name_addr);
     pj_list_init(&hdr->other_param);
     return hdr;
-}
-
-PJ_DEF(pjsip_route_hdr*) pjsip_route_hdr_create( pj_pool_t *pool )
-{
-    pjsip_route_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
+
+}
+
+PJ_DEF(pjsip_rr_hdr*) pjsip_rr_hdr_create( pj_pool_t *pool )
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_rr_hdr));
+    return pjsip_rr_hdr_init(pool, mem);
+}
+
+PJ_DEF(pjsip_route_hdr*) pjsip_route_hdr_init( pj_pool_t *pool,
+					       void *mem )
+{
+    pjsip_route_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
     init_hdr(hdr, PJSIP_H_ROUTE, &routing_hdr_vptr);
     pjsip_name_addr_init(&hdr->name_addr);
     pj_list_init(&hdr->other_param);
     return hdr;
+}
+
+PJ_DEF(pjsip_route_hdr*) pjsip_route_hdr_create( pj_pool_t *pool )
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_route_hdr));
+    return pjsip_route_hdr_init(pool, mem);
 }
 
@@ -1305,7 +1483,11 @@
  * Require header.
  */
-PJ_DEF(pjsip_require_hdr*) pjsip_require_hdr_create(pj_pool_t *pool)
-{
-    pjsip_require_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
+PJ_DEF(pjsip_require_hdr*) pjsip_require_hdr_init( pj_pool_t *pool,
+						   void *mem )
+{
+    pjsip_require_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
     init_hdr(hdr, PJSIP_H_REQUIRE, &generic_array_hdr_vptr);
     hdr->count = 0;
@@ -1313,14 +1495,32 @@
 }
 
+PJ_DEF(pjsip_require_hdr*) pjsip_require_hdr_create(pj_pool_t *pool)
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_require_hdr));
+    return pjsip_require_hdr_init(pool, mem);
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 /*
  * Retry-After header.
  */
-PJ_DEF(pjsip_retry_after_hdr*) pjsip_retry_after_hdr_create(pj_pool_t *pool)
-{
-    pjsip_retry_after_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
+PJ_DEF(pjsip_retry_after_hdr*) pjsip_retry_after_hdr_init( pj_pool_t *pool,
+							   void *mem,
+							   int value )
+{
+    pjsip_retry_after_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
     init_hdr(hdr, PJSIP_H_RETRY_AFTER, &generic_int_hdr_vptr);
-    hdr->ivalue = 0;
-    return hdr;
+    hdr->ivalue = value;
+    return hdr;
+}
+
+PJ_DEF(pjsip_retry_after_hdr*) pjsip_retry_after_hdr_create(pj_pool_t *pool,
+							    int value )
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_retry_after_hdr));
+    return pjsip_retry_after_hdr_init(pool, mem, value );
 }
 
@@ -1330,7 +1530,10 @@
  * Supported header.
  */
-PJ_DEF(pjsip_supported_hdr*) pjsip_supported_hdr_create(pj_pool_t *pool)
-{
-    pjsip_supported_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
+PJ_DEF(pjsip_supported_hdr*) pjsip_supported_hdr_init( pj_pool_t *pool,
+						       void *mem )
+{
+    pjsip_supported_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
     init_hdr(hdr, PJSIP_H_SUPPORTED, &generic_array_hdr_vptr);
     hdr->count = 0;
@@ -1338,4 +1541,10 @@
 }
 
+PJ_DEF(pjsip_supported_hdr*) pjsip_supported_hdr_create(pj_pool_t *pool)
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_supported_hdr));
+    return pjsip_supported_hdr_init(pool, mem);
+}
+
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -1343,10 +1552,20 @@
  * Unsupported header.
  */
-PJ_DEF(pjsip_unsupported_hdr*) pjsip_unsupported_hdr_create(pj_pool_t *pool)
-{
-    pjsip_unsupported_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
+PJ_DEF(pjsip_unsupported_hdr*) pjsip_unsupported_hdr_init( pj_pool_t *pool,
+							   void *mem )
+{
+    pjsip_unsupported_hdr *hdr = mem;
+    
+    PJ_UNUSED_ARG(pool);
+
     init_hdr(hdr, PJSIP_H_UNSUPPORTED, &generic_array_hdr_vptr);
     hdr->count = 0;
     return hdr;
+}
+
+PJ_DEF(pjsip_unsupported_hdr*) pjsip_unsupported_hdr_create(pj_pool_t *pool)
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_unsupported_hdr));
+    return pjsip_unsupported_hdr_init(pool, mem);
 }
 
@@ -1366,13 +1585,24 @@
 };
 
-PJ_DEF(pjsip_via_hdr*) pjsip_via_hdr_create( pj_pool_t *pool )
-{
-    pjsip_via_hdr *hdr = pj_pool_calloc(pool, 1, sizeof(*hdr));
+PJ_DEF(pjsip_via_hdr*) pjsip_via_hdr_init( pj_pool_t *pool,
+					   void *mem )
+{
+    pjsip_via_hdr *hdr = mem;
+
+    PJ_UNUSED_ARG(pool);
+
+    pj_memset(mem, 0, sizeof(pjsip_via_hdr));
     init_hdr(hdr, PJSIP_H_VIA, &via_hdr_vptr);
-    //hdr->sent_by.port = 5060;
     hdr->ttl_param = -1;
     hdr->rport_param = -1;
     pj_list_init(&hdr->other_param);
     return hdr;
+
+}
+
+PJ_DEF(pjsip_via_hdr*) pjsip_via_hdr_create( pj_pool_t *pool )
+{
+    void *mem = pj_pool_alloc(pool, sizeof(pjsip_via_hdr));
+    return pjsip_via_hdr_init(pool, mem);
 }
 
