[Freeswitch-svn] [commit] r4319 - in freeswitch/trunk/src: . include

Freeswitch SVN mikej at freeswitch.org
Sun Feb 18 21:21:28 EST 2007


Author: mikej
Date: Sun Feb 18 21:21:27 2007
New Revision: 4319

Modified:
   freeswitch/trunk/src/include/switch_core.h
   freeswitch/trunk/src/switch_core.c

Log:
add switch_core_session_sprintf which allocates from the session pool

Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h	(original)
+++ freeswitch/trunk/src/include/switch_core.h	Sun Feb 18 21:21:27 2007
@@ -393,6 +393,15 @@
 */
 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

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Sun Feb 18 21:21:27 2007
@@ -1465,6 +1465,22 @@
 	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)
 {



More information about the Freeswitch-svn mailing list