diff options
author | Tim Janik <timj@gtk.org> | 1998-09-02 14:57:10 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 1998-09-02 14:57:10 +0000 |
commit | 519435e6425cb0142d88c0a12da9c9b2cf7be923 (patch) | |
tree | 5cdc412c1c5fcad5e953b9c671d78f24f04d7daf /gstrfuncs.c | |
parent | 7401460a60504dad7b77219d0ba3d93112e12444 (diff) | |
download | glib-519435e6425cb0142d88c0a12da9c9b2cf7be923.tar.gz |
new function g_strnfill() to return a new string of specified length,
Wed Aug 26 06:32:40 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gstrfuncs.c: new function g_strnfill() to return a new string
of specified length, filled with a specific character.
Diffstat (limited to 'gstrfuncs.c')
-rw-r--r-- | gstrfuncs.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/gstrfuncs.c b/gstrfuncs.c index 46234dcc2..176985434 100644 --- a/gstrfuncs.c +++ b/gstrfuncs.c @@ -32,33 +32,52 @@ g_strdup (const gchar *str) { gchar *new_str; - new_str = NULL; if (str) { new_str = g_new (char, strlen (str) + 1); strcpy (new_str, str); } + else + new_str = NULL; return new_str; } gchar* -g_strndup (const gchar *str, gulong n) +g_strndup (const gchar *str, + guint n) { - char *new_str; + gchar *new_str; - new_str = NULL; if (str) { - new_str = g_new (char, n + 1); + new_str = g_new (gchar, n + 1); strncpy (new_str, str, n); new_str[n] = '\0'; } + else + new_str = NULL; return new_str; } gchar* +g_strnfill (guint length, + gchar fill_char) +{ + register gchar *str, *s, *end; + + str = g_new (gchar, length + 1); + s = str; + end = str + length; + while (s < end) + *(s++) = fill_char; + *s = 0; + + return str; +} + +gchar* g_strdup_vprintf (const gchar *format, va_list args1) { |