]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add pool allocated printf function switch_core_sprintf
authorMichael Jerris <mike@jerris.com>
Tue, 20 Feb 2007 21:54:23 +0000 (21:54 +0000)
committerMichael Jerris <mike@jerris.com>
Tue, 20 Feb 2007 21:54:23 +0000 (21:54 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4339 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_core.h
src/switch_core.c

index d55ecac949d9f7b7bceaa4d88e2b2034055eecfb..a88f00e923b9e79879471ff15ff00cef8de27b3e 100644 (file)
@@ -402,6 +402,15 @@ SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool_t *pool, const char
 */
 SWITCH_DECLARE(char *) switch_core_session_sprintf(switch_core_session_t *session, const char *fmt, ...);
 
+/*!
+  \brief printf-style style printing routine.  The data is output to a string allocated from the pool
+  \param pool a pool to use for allocation
+  \param fmt The format of the string
+  \param ... The arguments to use while printing the data
+  \return The new string
+*/
+SWITCH_DECLARE(char *) switch_core_sprintf(switch_memory_pool_t *pool, const char *fmt, ...);
+
 /*! 
   \brief Retrieve the memory pool from a session
   \param session the session to retrieve the pool from
index eec8aae8e34ce37008bec763089105b0dec3e3ba..95b99a71b3ddda5542ed5fa925ca6d7e100a3059 100644 (file)
@@ -1481,6 +1481,21 @@ SWITCH_DECLARE(char *) switch_core_session_sprintf(switch_core_session_t *sessio
        return result;
 }
 
+SWITCH_DECLARE(char *) switch_core_sprintf(switch_memory_pool_t *pool, const char *fmt, ...)
+{
+       va_list ap;
+       char *result = NULL;
+
+       assert(pool != NULL);
+       va_start(ap, fmt);
+       
+       result = apr_pvsprintf(pool ,fmt, ap);
+
+       va_end(ap);
+
+       return result;
+}
+
 
 SWITCH_DECLARE(char *) switch_core_session_strdup(switch_core_session_t *session, const char *todup)
 {