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

35
glib.h
View File

@ -1175,39 +1175,38 @@ gdouble g_timer_elapsed (GTimer *timer,
/* String utility functions
*/
#define G_STR_DELIMITERS "_-|> <."
void g_strdelimit (gchar *string,
#define G_STR_DELIMITERS "_-|> <."
void g_strdelimit (gchar *string,
const gchar *delimiters,
gchar new_delimiter);
gchar* g_strdup (const gchar *str);
gchar* g_strdup_printf (const gchar *format,
gchar* g_strdup (const gchar *str);
gchar* g_strdup_printf (const gchar *format,
...) G_GNUC_PRINTF (1, 2);
gchar* g_strdup_vprintf (const gchar *format,
gchar* g_strdup_vprintf (const gchar *format,
va_list args);
gchar* g_strndup (const gchar *str,
gchar* g_strndup (const gchar *str,
guint n);
gchar* g_strnfill (guint length,
gchar* g_strnfill (guint length,
gchar fill_char);
gchar* g_strconcat (const gchar *string1,
gchar* g_strconcat (const gchar *string1,
...); /* NULL terminated */
gdouble g_strtod (const gchar *nptr,
gdouble g_strtod (const gchar *nptr,
gchar **endptr);
gchar* g_strerror (gint errnum);
gchar* g_strsignal (gint signum);
gint g_strcasecmp (const gchar *s1,
gchar* g_strerror (gint errnum);
gchar* g_strsignal (gint signum);
gint g_strcasecmp (const gchar *s1,
const gchar *s2);
void g_strdown (gchar *string);
void g_strup (gchar *string);
void g_strreverse (gchar *string);
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

@ -1175,39 +1175,38 @@ gdouble g_timer_elapsed (GTimer *timer,
/* String utility functions
*/
#define G_STR_DELIMITERS "_-|> <."
void g_strdelimit (gchar *string,
#define G_STR_DELIMITERS "_-|> <."
void g_strdelimit (gchar *string,
const gchar *delimiters,
gchar new_delimiter);
gchar* g_strdup (const gchar *str);
gchar* g_strdup_printf (const gchar *format,
gchar* g_strdup (const gchar *str);
gchar* g_strdup_printf (const gchar *format,
...) G_GNUC_PRINTF (1, 2);
gchar* g_strdup_vprintf (const gchar *format,
gchar* g_strdup_vprintf (const gchar *format,
va_list args);
gchar* g_strndup (const gchar *str,
gchar* g_strndup (const gchar *str,
guint n);
gchar* g_strnfill (guint length,
gchar* g_strnfill (guint length,
gchar fill_char);
gchar* g_strconcat (const gchar *string1,
gchar* g_strconcat (const gchar *string1,
...); /* NULL terminated */
gdouble g_strtod (const gchar *nptr,
gdouble g_strtod (const gchar *nptr,
gchar **endptr);
gchar* g_strerror (gint errnum);
gchar* g_strsignal (gint signum);
gint g_strcasecmp (const gchar *s1,
gchar* g_strerror (gint errnum);
gchar* g_strsignal (gint signum);
gint g_strcasecmp (const gchar *s1,
const gchar *s2);
void g_strdown (gchar *string);
void g_strup (gchar *string);
void g_strreverse (gchar *string);
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*