]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add switch_core_session_sprintf which allocates from the session pool
authorMichael Jerris <mike@jerris.com>
Mon, 19 Feb 2007 02:21:27 +0000 (02:21 +0000)
committerMichael Jerris <mike@jerris.com>
Mon, 19 Feb 2007 02:21:27 +0000 (02:21 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4319 d0543943-73ff-0310-b7d9-9358b9ac24b2

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

index 876a0667a8bfe81492d177dba04a3223d08dbb4d..d55ecac949d9f7b7bceaa4d88e2b2034055eecfb 100644 (file)
@@ -393,6 +393,15 @@ SWITCH_DECLARE(char *) switch_core_session_strdup(switch_core_session_t *session
 */
 SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool_t *pool, const char *todup);
 
+/*!
+  \brief printf-style style printing routine.  The data is output to a string allocated from the session
+  \param session a session 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_session_sprintf(switch_core_session_t *session, const char *fmt, ...);
+
 /*! 
   \brief Retrieve the memory pool from a session
   \param session the session to retrieve the pool from
index 98ecc09d60c03afbfcf66cc85b2c58cc8e25bf3c..ee4ac2e8dec2f0e7f56a1e7eb62618162c720b2e 100644 (file)
@@ -1465,6 +1465,22 @@ SWITCH_DECLARE(char *) switch_core_permanent_strdup(const char *todup)
        return duped;
 }
 
+SWITCH_DECLARE(char *) switch_core_session_sprintf(switch_core_session_t *session, const char *fmt, ...)
+{
+       va_list ap;
+       char *result = NULL;
+
+       assert(session != NULL);
+       assert(session->pool != NULL);
+       va_start(ap, fmt);
+       
+       result = apr_pvsprintf(session->pool ,fmt, ap);
+
+       va_end(ap);
+
+       return result;
+}
+
 
 SWITCH_DECLARE(char *) switch_core_session_strdup(switch_core_session_t *session, const char *todup)
 {