mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-21 08:28:53 +02:00
minor g_memdup() fixups
This commit is contained in:
5
glib.h
5
glib.h
@@ -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
|
||||
*/
|
||||
|
@@ -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
|
||||
*/
|
||||
|
@@ -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*
|
||||
|
20
gstrfuncs.c
20
gstrfuncs.c
@@ -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*
|
||||
|
Reference in New Issue
Block a user