diff src/xs_stil.c @ 402:f997b79a7251

More work on merging of improved STIL/SLDB handling code with completely dynamic memory allocation.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 01 Jun 2006 02:18:02 +0000
parents b571000e1f8c
children 7f694e5a1493
line wrap: on
line diff
--- a/src/xs_stil.c	Wed May 31 22:52:00 2006 +0000
+++ b/src/xs_stil.c	Thu Jun 01 02:18:02 2006 +0000
@@ -41,22 +41,28 @@
 			(t_xs_stil_subnode **) g_realloc(pNode->subTunes,
 			(nsubTunes + 1) * sizeof(t_xs_stil_subnode **));
 
-		if (!pNode->subTunes)
+		if (!pNode->subTunes) {
+			xs_error("SubTune pointer structure realloc failed.\n");
 			return FALSE;
+		}
 		
 		/* Clear the newly allocated memory */
 		xs_memset(&(pNode->subTunes[pNode->nsubTunes]), 0,
 			(nsubTunes + 1 - pNode->nsubTunes) *
 			sizeof(t_xs_stil_subnode **));
+		
+		pNode->nsubTunes = nsubTunes + 1;
 	}
-			
+
 	/* Allocate memory for subTune */
 	if (!pNode->subTunes[nsubTunes]) {
 		pNode->subTunes[nsubTunes] = (t_xs_stil_subnode *)
 			g_malloc0(sizeof(t_xs_stil_subnode));
 		
-		if (!pNode->subTunes[nsubTunes])
+		if (!pNode->subTunes[nsubTunes]) {
+			xs_error("SubTune structure malloc failed!\n");
 			return FALSE;
+		}
 	}
 
 	return TRUE;
@@ -247,7 +253,7 @@
 				break;
 			}
 
-			if (xs_stildb_node_realloc(tmpNode, subEntry)) {
+			if (!xs_stildb_node_realloc(tmpNode, subEntry)) {
 				XS_STILDB_ERR(lineNum, inLine,
 					"Could not (re)allocate memory for subEntries!\n");
 				isError = TRUE;
@@ -265,13 +271,11 @@
 				tmpNode->subTunes[subEntry]->pAuthor = g_strdup(&inLine[9]);
 			} else if (strncmp(inLine, "  TITLE:", 8) == 0) {
 				XS_STILDB_MULTI;
-				inLine[eolPos++] = '\n';
-				inLine[eolPos++] = 0;
+				isMulti = TRUE;
 				xs_pstrcat(&(tmpNode->subTunes[subEntry]->pInfo), &inLine[2]);
 			} else if (strncmp(inLine, " ARTIST:", 8) == 0) {
 				XS_STILDB_MULTI;
-				inLine[eolPos++] = '\n';
-				inLine[eolPos++] = 0;
+				isMulti = TRUE;
 				xs_pstrcat(&(tmpNode->subTunes[subEntry]->pInfo), &inLine[1]);
 			} else if (strncmp(inLine, "COMMENT:", 8) == 0) {
 				XS_STILDB_MULTI;