changeset 1585:d41ee068b543

Merged STIL parser fixes from XMMS-SID.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 04 Sep 2007 03:24:11 +0300
parents a6115d004ec3
children deb342ef8598
files src/sid/xs_stil.c
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/sid/xs_stil.c	Mon Sep 03 23:43:38 2007 +0200
+++ b/src/sid/xs_stil.c	Tue Sep 04 03:24:11 2007 +0300
@@ -36,6 +36,8 @@
 
 	/* Re-allocate subTune structure if needed */
 	if (nsubTunes > pNode->nsubTunes) {
+		gint clearIndex, clearLength;
+		
 		pNode->subTunes =
 			(t_xs_stil_subnode **) g_realloc(pNode->subTunes,
 			(nsubTunes + 1) * sizeof(t_xs_stil_subnode **));
@@ -46,8 +48,14 @@
 		}
 		
 		/* Clear the newly allocated memory */
-		xs_memset(&(pNode->subTunes[pNode->nsubTunes]), 0,
-		(nsubTunes - pNode->nsubTunes + 1) * sizeof(t_xs_stil_subnode **));
+		if (pNode->nsubTunes == 0) {
+			clearIndex = 0;
+			clearLength = nsubTunes + 1;
+		} else {
+			clearIndex = pNode->nsubTunes + 1;
+			clearLength = (nsubTunes - clearIndex + 1);
+		}
+		xs_memset(&(pNode->subTunes[clearIndex]), 0, clearLength * sizeof(t_xs_stil_subnode **));
 		
 		pNode->nsubTunes = nsubTunes;
 	}
@@ -268,7 +276,7 @@
 			}
 			
 			/* Some other type */
-			if (strncmp(tmpLine, " NAME:", 8) == 0) {
+			if (strncmp(tmpLine, "   NAME:", 8) == 0) {
 				XS_STILDB_MULTI;
 				g_free(tmpNode->subTunes[subEntry]->pName);
 				tmpNode->subTunes[subEntry]->pName = g_strdup(&tmpLine[9]);