aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.de.marchi@gmail.com>2013-09-24 12:05:11 -0300
committerLucas De Marchi <lucas.de.marchi@gmail.com>2013-09-24 12:14:34 -0300
commita4830b45057052f176e46d1f7bece75d5c5a7842 (patch)
treede0eacbe9ab9d8cfaef392fd8363427567fcb398
parenteina: fix formatting of new functions (diff)
downloadefl-a4830b45057052f176e46d1f7bece75d5c5a7842.tar.gz
eina: use asprintf if available
-rw-r--r--configure.ac1
-rw-r--r--src/lib/eina/eina_str.c8
2 files changed, 8 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 426e6d8e5f..1911768b72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -530,6 +530,7 @@ mtrace \
realpath \
strlcpy \
geteuid \
+vasprintf \
])
AC_FUNC_ALLOCA
diff --git a/src/lib/eina/eina_str.c b/src/lib/eina/eina_str.c
index 2c51bb5bb8..dd67adb026 100644
--- a/src/lib/eina/eina_str.c
+++ b/src/lib/eina/eina_str.c
@@ -666,8 +666,13 @@ eina_str_vprintf_length(const char *format, va_list args)
EAPI char *
eina_str_vprintf_dup(const char *format, va_list args)
{
- size_t length;
char *ret;
+#if HAVE_VASPRINTF
+ if (vasprintf(&ret, format, args) < 0)
+ return NULL;
+ return ret;
+#else
+ size_t length;
va_list copy;
/* be sure to use a copy or the printf implementation will
@@ -680,6 +685,7 @@ eina_str_vprintf_dup(const char *format, va_list args)
ret = calloc(length, sizeof(char));
vsprintf(ret, format, args);
return ret;
+#endif
}
EAPI char *