minor g_memdup() fixups

This commit is contained in:
Tim Janik
1998-09-19 01:12:06 +00:00
parent 0dbf1d8cc4
commit eeb971d1b9
4 changed files with 62 additions and 48 deletions

5
glib.h
View File

@@ -1199,15 +1199,14 @@ gint g_strcasecmp (const gchar *s1,
void g_strdown (gchar *string);
void g_strup (gchar *string);
void g_strreverse (gchar *string);
gpointer g_memdup (gconstpointer mem,
guint byte_size);
/* calculate a string size, guarranteed to fit format + args.
*/
guint g_printf_string_upper_bound (const gchar* format,
va_list args);
guint8* g_memdup (const guint8 *mem,
guint len);
/* Retrive static string info
*/

View File

@@ -1199,15 +1199,14 @@ gint g_strcasecmp (const gchar *s1,
void g_strdown (gchar *string);
void g_strup (gchar *string);
void g_strreverse (gchar *string);
gpointer g_memdup (gconstpointer mem,
guint byte_size);
/* calculate a string size, guarranteed to fit format + args.
*/
guint g_printf_string_upper_bound (const gchar* format,
va_list args);
guint8* g_memdup (const guint8 *mem,
guint len);
/* Retrive static string info
*/

View File

@@ -43,13 +43,21 @@ g_strdup (const gchar *str)
return new_str;
}
guint8*
g_memdup (const guint8 *mem,
guint len)
gpointer
g_memdup (gconstpointer mem,
guint byte_size)
{
guint8* mem2 = g_malloc (len);
memcpy (mem2, mem, len);
return mem2;
gpointer new_mem;
if (mem)
{
new_mem = g_malloc (byte_size);
memcpy (new_mem, mem, byte_size);
}
else
new_mem = NULL;
return new_mem;
}
gchar*

View File

@@ -43,13 +43,21 @@ g_strdup (const gchar *str)
return new_str;
}
guint8*
g_memdup (const guint8 *mem,
guint len)
gpointer
g_memdup (gconstpointer mem,
guint byte_size)
{
guint8* mem2 = g_malloc (len);
memcpy (mem2, mem, len);
return mem2;
gpointer new_mem;
if (mem)
{
new_mem = g_malloc (byte_size);
memcpy (new_mem, mem, byte_size);
}
else
new_mem = NULL;
return new_mem;
}
gchar*