[asterisk-commits] trunk r18755 - in /trunk: include/asterisk/compat.h utils.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Apr 10 00:48:54 MST 2006


Author: tilghman
Date: Mon Apr 10 02:48:52 2006
New Revision: 18755

URL: http://svn.digium.com/view/asterisk?rev=18755&view=rev
Log:
Bug 6829 - asprintf for Solaris

Modified:
    trunk/include/asterisk/compat.h
    trunk/utils.c

Modified: trunk/include/asterisk/compat.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/compat.h?rev=18755&r1=18754&r2=18755&view=diff
==============================================================================
--- trunk/include/asterisk/compat.h (original)
+++ trunk/include/asterisk/compat.h Mon Apr 10 02:48:52 2006
@@ -71,6 +71,7 @@
 #endif
 #endif /* __CYGWIN__ */
 
+#define HAVE_ASPRINTF
 #define HAVE_VASPRINTF
 #define HAVE_STRTOQ
 
@@ -89,6 +90,7 @@
 #endif
 
 #ifdef SOLARIS
+#undef HAVE_ASPRINTF
 #undef HAVE_VASPRINTF
 #undef HAVE_STRTOQ
 #endif

Modified: trunk/utils.c
URL: http://svn.digium.com/view/asterisk/trunk/utils.c?rev=18755&r1=18754&r2=18755&view=diff
==============================================================================
--- trunk/utils.c (original)
+++ trunk/utils.c Mon Apr 10 02:48:52 2006
@@ -765,6 +765,40 @@
 	return size;
 }
 #endif /* !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC) */
+
+/*
+ * Based on Code from bsd-asprintf from OpenSSH
+ * Copyright (c) 2004 Darren Tucker.
+ *
+ * Based originally on asprintf.c from OpenBSD:
+ * Copyright (c) 1997 Todd C. Miller <Todd.Miller at courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) 
+int asprintf(char **str, const char *fmt, ...)
+{
+        va_list ap;
+        int ret;
+
+        *str = NULL;
+        va_start(ap, fmt);
+        ret = vasprintf(str, fmt, ap);
+        va_end(ap);
+
+        return ret;
+}
+#endif /* !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) */
 
 #ifndef HAVE_STRTOQ
 #ifndef LONG_MIN



More information about the asterisk-commits mailing list