diff options
author | Kalle Wallin <kaw@linux.se> | 2004-07-13 21:10:06 +0000 |
---|---|---|
committer | Kalle Wallin <kaw@linux.se> | 2004-07-13 21:10:06 +0000 |
commit | 9a500d13055f16b70796a5fce5ec6de4a2844187 (patch) | |
tree | 8f57c14c8454ee836597cc47ed7eedd3b6f4dabe /src/support.c | |
parent | e9f21b11c862ad168bb5a850730861e01ad6f3d8 (diff) | |
download | mpd-9a500d13055f16b70796a5fce5ec6de4a2844187.tar.gz mpd-9a500d13055f16b70796a5fce5ec6de4a2844187.tar.xz mpd-9a500d13055f16b70796a5fce5ec6de4a2844187.zip |
Use glib's str functions (g_strlcat, g_strlcpy, g_snprintf, g_strdup_vprintf)
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@1868 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/support.c')
-rw-r--r-- | src/support.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/support.c b/src/support.c index 3717e6c0f..254c15eb1 100644 --- a/src/support.c +++ b/src/support.c @@ -53,8 +53,8 @@ remove_trailing_slash(char *path) char * lowerstr(char *str) { - size_t i; - size_t len = strlen(str); + gsize i; + gsize len = strlen(str); if( str==NULL ) return NULL; @@ -100,8 +100,8 @@ strcasestr(const char *haystack, const char *needle) char * strscroll(char *str, char *separator, int width, scroll_state_t *st) { - char *tmp, *buf; - size_t len; + gchar *tmp, *buf; + gsize len, size; if( st->offset==0 ) { @@ -110,19 +110,21 @@ strscroll(char *str, char *separator, int width, scroll_state_t *st) } /* create a buffer containing the string and the separator */ - tmp = g_malloc(strlen(str)+strlen(separator)+1); - strcpy(tmp, str); - strcat(tmp, separator); + size = strlen(str)+strlen(separator)+1; + tmp = g_malloc(size); + g_strlcpy(tmp, str, size); + g_strlcat(tmp, separator, size); len = strlen(tmp); if( st->offset >= len ) st->offset = 0; /* create the new scrolled string */ - buf = g_malloc(width+1); - strncpy(buf, tmp+st->offset, width); + size = width+1; + buf = g_malloc(size); + g_strlcpy(buf, tmp+st->offset, size); if( strlen(buf) < width ) - strncat(buf, tmp, width-strlen(buf)); + g_strlcat(buf, tmp, size); if( time(NULL)-st->t >= 1 ) { |