changeset 2894:630c9662e0f1

No, no, no and no. "type identifier[variable]" is NOT a proper way to allocate tables (or strings, for that matter).
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 13 Aug 2008 01:57:40 +0300
parents 6a6f27de82aa
children 92fc55b8da15
files src/streambrowser/xiph.c
diffstat 1 files changed, 4 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/streambrowser/xiph.c	Wed Aug 13 01:01:25 2008 +0300
+++ b/src/streambrowser/xiph.c	Wed Aug 13 01:57:40 2008 +0300
@@ -226,21 +226,16 @@
 
 static gboolean genre_match(gchar *string1, gchar *string2)
 {
-	char *saveptr = NULL;
-	char *token;
+	gchar *saveptr = NULL, *token;
 	gboolean matched = FALSE;
-	char temp1[strlen(string1) + 1];
-	char temp2[strlen(string2) + 1];
+	gchar *temp1 = g_strdup(string1),
+		*temp2 = g_strdup(string2);
 
-	/* these are required for strtok_r to work properly */	
-	strcpy(temp1, string1);
-	strcpy(temp2, string2);
-	
 	token = strtok_r(temp1, " ", &saveptr);
 	while (token != NULL) {
 		if (mystrcasestr(temp2, token))
 			matched = TRUE;
-			
+		
 		token = strtok_r(NULL, " ", &saveptr);
 	}