+Wed Sep 19 14:17:31 2001 Owen Taylor <otaylor@redhat.com>
+
+ Patch from Matthias Clasen (#59806)
+
+ * configure.in: Check for vasprintf().
+
+ * glib/gmem.[ch]: Add g_mem_vtable_is_set() to be used
+ for efficiency hacks to avoid extra copies when not
+ needed.
+
+ * glib/gstrfuncs.c: Use vasprintf() to implement
+ g_strdup_printf() when available.
+
+ * glib/gmessages.c (g_logv): Avoid using
+ printf_string_upper_bound() when we have have vsnprintf.
+
+ * glib/gmessages.c (printf_string_upper_bound): Don't
+ segfault when warning about positional parameters.
+
Wed Sep 19 14:05:27 2001 Owen Taylor <otaylor@redhat.com>
* glib/{gcache.c,gmem.c,grel.c,gstring.c,gtimer.c,gtree}:
+Wed Sep 19 14:17:31 2001 Owen Taylor <otaylor@redhat.com>
+
+ Patch from Matthias Clasen (#59806)
+
+ * configure.in: Check for vasprintf().
+
+ * glib/gmem.[ch]: Add g_mem_vtable_is_set() to be used
+ for efficiency hacks to avoid extra copies when not
+ needed.
+
+ * glib/gstrfuncs.c: Use vasprintf() to implement
+ g_strdup_printf() when available.
+
+ * glib/gmessages.c (g_logv): Avoid using
+ printf_string_upper_bound() when we have have vsnprintf.
+
+ * glib/gmessages.c (printf_string_upper_bound): Don't
+ segfault when warning about positional parameters.
+
Wed Sep 19 14:05:27 2001 Owen Taylor <otaylor@redhat.com>
* glib/{gcache.c,gmem.c,grel.c,gstring.c,gtimer.c,gtree}:
+Wed Sep 19 14:17:31 2001 Owen Taylor <otaylor@redhat.com>
+
+ Patch from Matthias Clasen (#59806)
+
+ * configure.in: Check for vasprintf().
+
+ * glib/gmem.[ch]: Add g_mem_vtable_is_set() to be used
+ for efficiency hacks to avoid extra copies when not
+ needed.
+
+ * glib/gstrfuncs.c: Use vasprintf() to implement
+ g_strdup_printf() when available.
+
+ * glib/gmessages.c (g_logv): Avoid using
+ printf_string_upper_bound() when we have have vsnprintf.
+
+ * glib/gmessages.c (printf_string_upper_bound): Don't
+ segfault when warning about positional parameters.
+
Wed Sep 19 14:05:27 2001 Owen Taylor <otaylor@redhat.com>
* glib/{gcache.c,gmem.c,grel.c,gstring.c,gtimer.c,gtree}:
+Wed Sep 19 14:17:31 2001 Owen Taylor <otaylor@redhat.com>
+
+ Patch from Matthias Clasen (#59806)
+
+ * configure.in: Check for vasprintf().
+
+ * glib/gmem.[ch]: Add g_mem_vtable_is_set() to be used
+ for efficiency hacks to avoid extra copies when not
+ needed.
+
+ * glib/gstrfuncs.c: Use vasprintf() to implement
+ g_strdup_printf() when available.
+
+ * glib/gmessages.c (g_logv): Avoid using
+ printf_string_upper_bound() when we have have vsnprintf.
+
+ * glib/gmessages.c (printf_string_upper_bound): Don't
+ segfault when warning about positional parameters.
+
Wed Sep 19 14:05:27 2001 Owen Taylor <otaylor@redhat.com>
* glib/{gcache.c,gmem.c,grel.c,gstring.c,gtimer.c,gtree}:
+Wed Sep 19 14:17:31 2001 Owen Taylor <otaylor@redhat.com>
+
+ Patch from Matthias Clasen (#59806)
+
+ * configure.in: Check for vasprintf().
+
+ * glib/gmem.[ch]: Add g_mem_vtable_is_set() to be used
+ for efficiency hacks to avoid extra copies when not
+ needed.
+
+ * glib/gstrfuncs.c: Use vasprintf() to implement
+ g_strdup_printf() when available.
+
+ * glib/gmessages.c (g_logv): Avoid using
+ printf_string_upper_bound() when we have have vsnprintf.
+
+ * glib/gmessages.c (printf_string_upper_bound): Don't
+ segfault when warning about positional parameters.
+
Wed Sep 19 14:05:27 2001 Owen Taylor <otaylor@redhat.com>
* glib/{gcache.c,gmem.c,grel.c,gstring.c,gtimer.c,gtree}:
+Wed Sep 19 14:17:31 2001 Owen Taylor <otaylor@redhat.com>
+
+ Patch from Matthias Clasen (#59806)
+
+ * configure.in: Check for vasprintf().
+
+ * glib/gmem.[ch]: Add g_mem_vtable_is_set() to be used
+ for efficiency hacks to avoid extra copies when not
+ needed.
+
+ * glib/gstrfuncs.c: Use vasprintf() to implement
+ g_strdup_printf() when available.
+
+ * glib/gmessages.c (g_logv): Avoid using
+ printf_string_upper_bound() when we have have vsnprintf.
+
+ * glib/gmessages.c (printf_string_upper_bound): Don't
+ segfault when warning about positional parameters.
+
Wed Sep 19 14:05:27 2001 Owen Taylor <otaylor@redhat.com>
* glib/{gcache.c,gmem.c,grel.c,gstring.c,gtimer.c,gtree}:
+Wed Sep 19 14:17:31 2001 Owen Taylor <otaylor@redhat.com>
+
+ Patch from Matthias Clasen (#59806)
+
+ * configure.in: Check for vasprintf().
+
+ * glib/gmem.[ch]: Add g_mem_vtable_is_set() to be used
+ for efficiency hacks to avoid extra copies when not
+ needed.
+
+ * glib/gstrfuncs.c: Use vasprintf() to implement
+ g_strdup_printf() when available.
+
+ * glib/gmessages.c (g_logv): Avoid using
+ printf_string_upper_bound() when we have have vsnprintf.
+
+ * glib/gmessages.c (printf_string_upper_bound): Don't
+ segfault when warning about positional parameters.
+
Wed Sep 19 14:05:27 2001 Owen Taylor <otaylor@redhat.com>
* glib/{gcache.c,gmem.c,grel.c,gstring.c,gtimer.c,gtree}:
+Wed Sep 19 14:17:31 2001 Owen Taylor <otaylor@redhat.com>
+
+ Patch from Matthias Clasen (#59806)
+
+ * configure.in: Check for vasprintf().
+
+ * glib/gmem.[ch]: Add g_mem_vtable_is_set() to be used
+ for efficiency hacks to avoid extra copies when not
+ needed.
+
+ * glib/gstrfuncs.c: Use vasprintf() to implement
+ g_strdup_printf() when available.
+
+ * glib/gmessages.c (g_logv): Avoid using
+ printf_string_upper_bound() when we have have vsnprintf.
+
+ * glib/gmessages.c (printf_string_upper_bound): Don't
+ segfault when warning about positional parameters.
+
Wed Sep 19 14:05:27 2001 Owen Taylor <otaylor@redhat.com>
* glib/{gcache.c,gmem.c,grel.c,gstring.c,gtimer.c,gtree}:
return mem;
}
+static gboolean vtable_set = FALSE;
+
+/**
+ * g_mem_vtable_is_set:
+ *
+ * Checks whether a custom vtable as been set by g_mem_set_vtable.
+ * If a custom vtable has not been set, memory allocated with
+ * free() can be used interchangeable with memory allocated using
+ * g_free(). This function is useful for avoiding an extra copy
+ * of allocated memory returned by a non-GLib-based API.
+ *
+ * Return value: if %TRUE, a custom vtable has been set.
+ **/
+gboolean
+g_mem_vtable_is_set (void)
+{
+ return vtable_set;
+}
+
void
g_mem_set_vtable (GMemVTable *vtable)
{
- static gboolean vtable_set = FALSE;
-
if (!vtable_set)
{
vtable_set = TRUE;
gsize n_bytes);
};
void g_mem_set_vtable (GMemVTable *vtable);
-
+gboolean g_mem_vtable_is_set (void);
/* Memory profiler and checker, has to be enabled via g_mem_set_vtable()
*/
/* we use a stack buffer of fixed size, because we might get called
* recursively.
*/
+#ifdef HAVE_VSNPRINTF
+ vsnprintf (buffer, 1024, format, args1);
+#else /* !HAVE_VSNPRINTF */
G_VA_COPY (args2, args1);
if (printf_string_upper_bound (format, FALSE, args1) < 1024)
vsprintf (buffer, format, args2);
else
{
/* since we might be out of memory, we can't use g_vsnprintf(). */
-#ifdef HAVE_VSNPRINTF
- vsnprintf (buffer, 1024, format, args2);
-#else /* !HAVE_VSNPRINTF */
/* we are out of luck here */
strncpy (buffer, format, 1024);
-#endif /* !HAVE_VSNPRINTF */
buffer[1024] = 0;
}
va_end (args2);
+#endif /* !HAVE_VSNPRINTF */
for (i = g_bit_nth_msf (log_level, -1); i >= 0; i = g_bit_nth_msf (log_level, i))
{
g_warning (G_GNUC_PRETTY_FUNCTION
"(): unable to handle positional parameters (%%n$)");
len += 1024; /* try adding some safety padding */
+ conv_done = TRUE;
break;
/* parse flags
va_list args1)
{
gchar *buffer;
+#ifdef HAVE_VASPRINTF
+ vasprintf (&buffer, format, args1);
+ if (g_mem_vtable_is_set ())
+ {
+ gchar *buffer1 = g_strdup (buffer);
+ free (buffer);
+ buffer = buffer1;
+ }
+#else
va_list args2;
G_VA_COPY (args2, args1);
vsprintf (buffer, format, args2);
va_end (args2);
-
+#endif
return buffer;
}