author | Francesco Abbate <francesco.bbt@gmail.com> | 2009年11月18日 19:31:25 +0000 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2009年11月18日 19:31:25 +0000 |
commit | b2d5b7d64100164e40e3141094736f2ac010a69f (patch) | |
tree | 41ac9a78eea0c8c677b7dff6e6a46f5f901fae19 /agg-plot/string_printf.cpp | |
parent | e8a10279d92ab7a66402bae02a8fc423a6162fd5 (diff) | |
download | gsl-shell-b2d5b7d64100164e40e3141094736f2ac010a69f.tar.gz |
-rw-r--r-- | agg-plot/string_printf.cpp | 24 |
diff --git a/agg-plot/string_printf.cpp b/agg-plot/string_printf.cpp new file mode 100644 index 00000000..884550bd --- /dev/null +++ b/agg-plot/string_printf.cpp @@ -0,0 +1,24 @@ + +#include <string> +#include <stdarg.h> + +void +string_printf (std::string &s, const char *fmt, ...) +{ + va_list ap; + char *buf; + int n; + + va_start (ap, fmt); + + n = vasprintf (&buf, fmt, ap); + if (n <= 0) + { + s = ""; + return; + } + + s = (const char *) buf; + free (buf); + va_end (ap); +} |