Use g_strndup, not g_strdup, since we know the length in advance.
authorMatthias Clasen <maclas@gmx.de>
Wed, 26 Feb 2003 00:12:42 +0000 (00:12 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 26 Feb 2003 00:12:42 +0000 (00:12 +0000)
2003-02-26  Matthias Clasen  <maclas@gmx.de>

* glib/gstrfuncs.c (g_strdup_vprintf): Use g_strndup, not
g_strdup, since we know the length in advance.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
glib/gstrfuncs.c

index 636d299..c274f14 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2003-02-26  Matthias Clasen  <maclas@gmx.de>
 
+       * glib/gstrfuncs.c (g_strdup_vprintf): Use g_strndup, not
+       g_strdup, since we know the length in advance.
+
        * glib/gunidecomp.c (g_unicode_canonical_decomposition): Use
        g_malloc instead of directly using malloc.
 
index 636d299..c274f14 100644 (file)
@@ -1,5 +1,8 @@
 2003-02-26  Matthias Clasen  <maclas@gmx.de>
 
+       * glib/gstrfuncs.c (g_strdup_vprintf): Use g_strndup, not
+       g_strdup, since we know the length in advance.
+
        * glib/gunidecomp.c (g_unicode_canonical_decomposition): Use
        g_malloc instead of directly using malloc.
 
index 636d299..c274f14 100644 (file)
@@ -1,5 +1,8 @@
 2003-02-26  Matthias Clasen  <maclas@gmx.de>
 
+       * glib/gstrfuncs.c (g_strdup_vprintf): Use g_strndup, not
+       g_strdup, since we know the length in advance.
+
        * glib/gunidecomp.c (g_unicode_canonical_decomposition): Use
        g_malloc instead of directly using malloc.
 
index 636d299..c274f14 100644 (file)
@@ -1,5 +1,8 @@
 2003-02-26  Matthias Clasen  <maclas@gmx.de>
 
+       * glib/gstrfuncs.c (g_strdup_vprintf): Use g_strndup, not
+       g_strdup, since we know the length in advance.
+
        * glib/gunidecomp.c (g_unicode_canonical_decomposition): Use
        g_malloc instead of directly using malloc.
 
index 636d299..c274f14 100644 (file)
@@ -1,5 +1,8 @@
 2003-02-26  Matthias Clasen  <maclas@gmx.de>
 
+       * glib/gstrfuncs.c (g_strdup_vprintf): Use g_strndup, not
+       g_strdup, since we know the length in advance.
+
        * glib/gunidecomp.c (g_unicode_canonical_decomposition): Use
        g_malloc instead of directly using malloc.
 
index 636d299..c274f14 100644 (file)
@@ -1,5 +1,8 @@
 2003-02-26  Matthias Clasen  <maclas@gmx.de>
 
+       * glib/gstrfuncs.c (g_strdup_vprintf): Use g_strndup, not
+       g_strdup, since we know the length in advance.
+
        * glib/gunidecomp.c (g_unicode_canonical_decomposition): Use
        g_malloc instead of directly using malloc.
 
index 9d1bf7d..5eee1d9 100644 (file)
@@ -51,7 +51,7 @@
 #endif
 
 /* do not include <unistd.h> in this place since it
- * inteferes with g_strsignal() on some OSes
+ * interferes with g_strsignal() on some OSes
  */
 
 static const guint16 ascii_table_data[256] = {
@@ -183,11 +183,13 @@ g_strdup_vprintf (const gchar *format,
 {
   gchar *buffer;
 #ifdef HAVE_VASPRINTF
-  if (_g_vasprintf (&buffer, format, args1) < 0)
+  gint len;
+  len = _g_vasprintf (&buffer, format, args1);
+  if (len < 0)
     buffer = NULL;
   else if (!g_mem_is_system_malloc ()) 
     {
-      gchar *buffer1 = g_strdup (buffer);
+      gchar *buffer1 = g_strndup (buffer, len);
       free (buffer);
       buffer = buffer1;
     }