Added pj_strdup2_with_null

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@263 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjlib/include/pj/string.h b/pjlib/include/pj/string.h
index 34134fd..acc1ddf 100644
--- a/pjlib/include/pj/string.h
+++ b/pjlib/include/pj/string.h
@@ -215,9 +215,11 @@
 /**
  * Duplicate string and NULL terminate the destination string.
  *
- * @param pool
- * @param dst
- * @param src
+ * @param pool	    The pool.
+ * @param dst	    The string result.
+ * @param src	    The string to duplicate.
+ *
+ * @return	    The string result.
  */
 PJ_IDECL(pj_str_t*) pj_strdup_with_null(pj_pool_t *pool,
 					pj_str_t *dst,
@@ -237,6 +239,20 @@
 			       const char *src);
 
 /**
+ * Duplicate string and NULL terminate the destination string.
+ *
+ * @param pool	    The pool.
+ * @param dst	    The string result.
+ * @param src	    The string to duplicate.
+ *
+ * @return	    The string result.
+ */
+PJ_IDECL(pj_str_t*) pj_strdup2_with_null(pj_pool_t *pool,
+					 pj_str_t *dst,
+					 const char *src);
+
+
+/**
  * Duplicate string.
  *
  * @param pool	    The pool.
diff --git a/pjlib/include/pj/string_i.h b/pjlib/include/pj/string_i.h
index 928c885..25fc036 100644
--- a/pjlib/include/pj/string_i.h
+++ b/pjlib/include/pj/string_i.h
@@ -43,11 +43,9 @@
 					pj_str_t *dst,
 					const pj_str_t *src)
 {
+    dst->ptr = (char*)pj_pool_alloc(pool, src->slen+1);
     if (src->slen) {
-	dst->ptr = (char*)pj_pool_alloc(pool, src->slen+1);
 	pj_memcpy(dst->ptr, src->ptr, src->slen);
-    } else {
-	dst->ptr = (char*)pj_pool_alloc(pool, 1);
     }
     dst->slen = src->slen;
     dst->ptr[dst->slen] = '\0';
@@ -68,6 +66,18 @@
     return dst;
 }
 
+PJ_IDEF(pj_str_t*) pj_strdup2_with_null( pj_pool_t *pool,
+					 pj_str_t *dst,
+					 const char *src)
+{
+    dst->slen = src ? pj_ansi_strlen(src) : 0;
+    dst->ptr = (char*)pj_pool_alloc(pool, dst->slen+1);
+    if (dst->slen) {
+	pj_memcpy(dst->ptr, src, dst->slen);
+    }
+    dst->ptr[dst->slen] = '\0';
+    return dst;
+}
 
 PJ_IDEF(pj_str_t) pj_strdup3(pj_pool_t *pool, const char *src)
 {