GNOME Bugzilla – Bug 112365
add g_strdup_vprintf_len
Last modified: 2011-02-18 16:07:08 UTC
it would be useful to avoid some strlens which in turn would allow to handle embedded nuls in some places (see the bugs depending on this)
Created attachment 16314 [details] [review] patch
Looks basically fine ... I'm not sure about the name and signature. Having an out int as the first parameter is distinctly unusual and _len normally signifies a char*/len pair is being passed in. I can't think of a better name, but for the signature perhaps gboolean g_strdup_vprintf_len (gchar **buffer, gint *len, gchar *format, ...); (g_memdup_vprintf() would be an accurate name, but not a particularly obvious one.)
How about gchar *g_strdup_vprintf_size (const gchar *format, gint *size, va_list args) I think as long as the name starts with g_strdup, we should keep the gchar * return. Otherwise, we could simply go for gint g_vasprintf (gchar **buffer, const gchar *format, va_list args)
Of the ideas, I like the idea of a g_vasprintf() with exactly the same arguments as the GNU functions best.
I've added g_vasprintf() now.