From: Manish Singh Date: Wed, 19 Aug 1998 01:24:13 +0000 (+0000) Subject: added g_strndup X-Git-Tag: GLIB_1_1_3a~31 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=47074edbbd640197493bf048c125476fb43e54af;p=platform%2Fupstream%2Fglib.git added g_strndup -Yosh --- diff --git a/ChangeLog b/ChangeLog index 3286f5876..c111e7bbf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Aug 18 18:23:09 PDT 1998 Manish Singh + + * glib.h + * gstrfuncs.c: added g_strndup + Tue Aug 18 04:40:17 1998 Tim Janik * glib.h: diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 3286f5876..c111e7bbf 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,8 @@ +Tue Aug 18 18:23:09 PDT 1998 Manish Singh + + * glib.h + * gstrfuncs.c: added g_strndup + Tue Aug 18 04:40:17 1998 Tim Janik * glib.h: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 3286f5876..c111e7bbf 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +Tue Aug 18 18:23:09 PDT 1998 Manish Singh + + * glib.h + * gstrfuncs.c: added g_strndup + Tue Aug 18 04:40:17 1998 Tim Janik * glib.h: diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 3286f5876..c111e7bbf 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,8 @@ +Tue Aug 18 18:23:09 PDT 1998 Manish Singh + + * glib.h + * gstrfuncs.c: added g_strndup + Tue Aug 18 04:40:17 1998 Tim Janik * glib.h: diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 3286f5876..c111e7bbf 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,8 @@ +Tue Aug 18 18:23:09 PDT 1998 Manish Singh + + * glib.h + * gstrfuncs.c: added g_strndup + Tue Aug 18 04:40:17 1998 Tim Janik * glib.h: diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 3286f5876..c111e7bbf 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,8 @@ +Tue Aug 18 18:23:09 PDT 1998 Manish Singh + + * glib.h + * gstrfuncs.c: added g_strndup + Tue Aug 18 04:40:17 1998 Tim Janik * glib.h: diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 3286f5876..c111e7bbf 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,8 @@ +Tue Aug 18 18:23:09 PDT 1998 Manish Singh + + * glib.h + * gstrfuncs.c: added g_strndup + Tue Aug 18 04:40:17 1998 Tim Janik * glib.h: diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 3286f5876..c111e7bbf 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,8 @@ +Tue Aug 18 18:23:09 PDT 1998 Manish Singh + + * glib.h + * gstrfuncs.c: added g_strndup + Tue Aug 18 04:40:17 1998 Tim Janik * glib.h: diff --git a/glib.h b/glib.h index b9b16831c..8dacdf134 100644 --- a/glib.h +++ b/glib.h @@ -1106,6 +1106,8 @@ void g_strdelimit (gchar *string, const gchar *delimiters, gchar new_delimiter); gchar* g_strdup (const gchar *str); +gchar* g_strndup (const gchar *str, + gulong n); gchar* g_strconcat (const gchar *string1, ...); /* NULL terminated */ gdouble g_strtod (const gchar *nptr, diff --git a/glib/glib.h b/glib/glib.h index b9b16831c..8dacdf134 100644 --- a/glib/glib.h +++ b/glib/glib.h @@ -1106,6 +1106,8 @@ void g_strdelimit (gchar *string, const gchar *delimiters, gchar new_delimiter); gchar* g_strdup (const gchar *str); +gchar* g_strndup (const gchar *str, + gulong n); gchar* g_strconcat (const gchar *string1, ...); /* NULL terminated */ gdouble g_strtod (const gchar *nptr, diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c index 71d24ec43..187e5d32f 100644 --- a/glib/gstrfuncs.c +++ b/glib/gstrfuncs.c @@ -42,6 +42,22 @@ g_strdup (const gchar *str) return new_str; } +gchar* +g_strndup (const gchar *str, gulong n) +{ + char *new_str; + + new_str = NULL; + if (str) + { + new_str = g_new (char, n + 1); + strncpy (new_str, str, n); + new_str[n] = '\0'; + } + + return new_str; +} + gchar* g_strconcat (const gchar *string1, ...) { diff --git a/gstrfuncs.c b/gstrfuncs.c index 71d24ec43..187e5d32f 100644 --- a/gstrfuncs.c +++ b/gstrfuncs.c @@ -42,6 +42,22 @@ g_strdup (const gchar *str) return new_str; } +gchar* +g_strndup (const gchar *str, gulong n) +{ + char *new_str; + + new_str = NULL; + if (str) + { + new_str = g_new (char, n + 1); + strncpy (new_str, str, n); + new_str[n] = '\0'; + } + + return new_str; +} + gchar* g_strconcat (const gchar *string1, ...) {