diff src/stringref.c @ 7767:1f4005fcd872

[gaim-migrate @ 8412] As Nathan pointed out, a printf'd stringref is probably desirable committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Fri, 05 Dec 2003 17:28:22 +0000
parents dc79649b829d
children 4e5c48ea9478
line wrap: on
line diff
--- a/src/stringref.c	Fri Dec 05 17:09:18 2003 +0000
+++ b/src/stringref.c	Fri Dec 05 17:28:22 2003 +0000
@@ -25,6 +25,7 @@
 #include "internal.h"
 
 #include <string.h>
+#include <stdarg.h>
 
 #include "stringref.h"
 
@@ -39,6 +40,22 @@
 	return newref;
 }
 
+GaimStringref *gaim_stringref_printf(const char *format, ...)
+{
+	GaimStringref *newref;
+	va_list ap;
+
+	if (format == NULL)
+		return NULL;
+
+	va_start(ap, format);
+	newref = g_malloc(sizeof(GaimStringref) + g_printf_string_upper_bound(format, ap));
+	vsprintf(newref->value, format, ap);
+	va_end(ap);
+
+	return newref;
+}
+
 GaimStringref *gaim_stringref_ref(GaimStringref *stringref)
 {
 	if (stringref == NULL)