[svn-commits] jamesgolovich: branch jamesgolovich/chan_sip-ast_str r101768 - in /team/james...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Feb 1 01:20:48 CST 2008


Author: jamesgolovich
Date: Fri Feb  1 01:20:48 2008
New Revision: 101768

URL: http://svn.digium.com/view/asterisk?view=rev&rev=101768
Log:
Remove ast_str_dup


Modified:
    team/jamesgolovich/chan_sip-ast_str/channels/chan_sip.c
    team/jamesgolovich/chan_sip-ast_str/include/asterisk/strings.h

Modified: team/jamesgolovich/chan_sip-ast_str/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/jamesgolovich/chan_sip-ast_str/channels/chan_sip.c?view=diff&rev=101768&r1=101767&r2=101768
==============================================================================
--- team/jamesgolovich/chan_sip-ast_str/channels/chan_sip.c (original)
+++ team/jamesgolovich/chan_sip-ast_str/channels/chan_sip.c Fri Feb  1 01:20:48 2008
@@ -8095,7 +8095,12 @@
 
 	/* First copy stuff */
 	memcpy(dst, src, sizeof(*dst));
-	if (!(dst->data = ast_str_dup(src->data, dup)))
+	dst->data = dup;
+
+	if (!dst->data && !(dst->data = ast_str_create(src->data->used)))
+		return;
+		
+	if (ast_str_set(&dst->data, 0, "%s", src->data->str) == AST_DYNSTR_BUILD_FAILED) 
 		return;
 	offset = ((void *)dst->data->str) - ((void *)src->data->str);
 	/* Now fix pointer arithmetic */

Modified: team/jamesgolovich/chan_sip-ast_str/include/asterisk/strings.h
URL: http://svn.digium.com/view/asterisk/team/jamesgolovich/chan_sip-ast_str/include/asterisk/strings.h?view=diff&rev=101768&r1=101767&r2=101768
==============================================================================
--- team/jamesgolovich/chan_sip-ast_str/include/asterisk/strings.h (original)
+++ team/jamesgolovich/chan_sip-ast_str/include/asterisk/strings.h Fri Feb  1 01:20:48 2008
@@ -301,10 +301,6 @@
  *		creates a malloc()'ed dynamic string associated to
  *		the thread-local storage key ts
  *
- *	ds = ast_str_dup(orig, dest)
- *		duplicates an ast_str, if dest already exists and 
- *		is too small then it will be expanded and re-used
- *
  * Finally, the string can be manipulated with the following:
  *
  *	ast_str_set(&buf, max_len, fmt, ...)
@@ -420,39 +416,6 @@
 }
 )
 
-/*!
- * \brief Duplicate a malloc'ed dynamic length string
- *
- * \arg buf The ast_str to duplicate
- * \arg dup The ast_str to be duplicated into, if dup already exists and
- *		is too small then it will be expanded
- *
- * \return This function returns a pointer to the dynamic string length.  The
- *         result will be NULL in the case of a memory allocation error.
- *
- * \note The result of this function is dynamically allocated memory, and must
- *       be free()'d after it is no longer needed.
- */
-AST_INLINE_API(
-struct ast_str * attribute_malloc ast_str_dup(struct ast_str *buf, struct ast_str *dup),
-{
-	if (dup) {
-		if (buf->len > dup->len) 
-			ast_str_make_space(&dup, buf->len);
-	} else
-		dup = (struct ast_str *)ast_calloc(1, sizeof(*buf) + buf->len);
-	if (dup == NULL)
-		return NULL;
-	
-	dup->len = buf->len;
-	dup->used = buf->used;
-	dup->ts = buf->ts;
-	memcpy(dup->str, buf->str, buf->len);
-
-	return dup;
-}
-)
-
 #define ast_str_alloca(init_len)			\
 	({						\
 		struct ast_str *buf;			\




More information about the svn-commits mailing list