Index: glib/gstrfuncs.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gstrfuncs.c,v
retrieving revision 1.96
diff -u -b -B -p -r1.96 gstrfuncs.c
--- glib/gstrfuncs.c	5 May 2003 18:26:38 -0000	1.96
+++ glib/gstrfuncs.c	6 May 2003 21:53:05 -0000
@@ -177,13 +177,28 @@ g_stpcpy (gchar       *dest,
 #endif
 }
 
+/**
+ * g_strdup_vprintf_len:
+ * @length: a return location for the length of the returned string or %NULL.
+ * @format: the standard printf() format string.
+ * @args1: the list of parameters to insert into the format string.
+ * 
+ * Similar to the standard C vsprintf() function but safer, since it 
+ * calculates the maximum space required and allocates memory to hold 
+ * the result.
+ *
+ * Return value: a newly allocated string holding the result.
+ *
+ * Since: 2.4
+ **/
 gchar*
-g_strdup_vprintf (const gchar *format,
+g_strdup_vprintf_len (gint        *length,
+		      const gchar *format,
 		  va_list      args1)
 {
   gchar *buffer;
-#ifdef HAVE_VASPRINTF
   gint len;
+#ifdef HAVE_VASPRINTF
   len = _g_vasprintf (&buffer, format, args1);
   if (len < 0)
     buffer = NULL;
@@ -200,10 +215,20 @@ g_strdup_vprintf (const gchar *format,
 
   buffer = g_new (gchar, g_printf_string_upper_bound (format, args1));
 
-  _g_vsprintf (buffer, format, args2);
+  len = _g_vsprintf (buffer, format, args2);
   va_end (args2);
 #endif
+  if (length)
+    *length = len;
+
   return buffer;
+}
+
+gchar*
+g_strdup_vprintf (const gchar *format,
+		  va_list      args1)
+{
+  return g_strdup_vprintf_len (NULL, format, args1);
 }
 
 gchar*
Index: glib/gstrfuncs.h
===================================================================
RCS file: /cvs/gnome/glib/glib/gstrfuncs.h,v
retrieving revision 1.19
diff -u -b -B -p -r1.19 gstrfuncs.h
--- glib/gstrfuncs.h	12 Oct 2002 19:37:48 -0000	1.19
+++ glib/gstrfuncs.h	6 May 2003 21:53:05 -0000
@@ -184,6 +184,9 @@ gchar*	              g_strdup_printf  (c
 					...) G_GNUC_PRINTF (1, 2);
 gchar*	              g_strdup_vprintf (const gchar *format,
 					va_list      args);
+gchar*	              g_strdup_vprintf_len (gint        *length,
+                                            const gchar *format,
+					    va_list      args);
 gchar*	              g_strndup	       (const gchar *str,
 					gsize        n);  
 gchar*	              g_strnfill       (gsize        length,  
