Mercurial > hg > xmms-sid
diff src/xs_length.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 | b09d74eb71e6 |
children | 7f694e5a1493 |
line wrap: on
line diff
--- a/src/xs_length.c Wed May 31 22:52:00 2006 +0000 +++ b/src/xs_length.c Thu Jun 01 02:18:02 2006 +0000 @@ -103,7 +103,7 @@ */ t_xs_sldb_node * xs_sldb_read_entry(gchar *inLine) { - gint linePos, savePos, i, tmpLen; + gint linePos, savePos, i, tmpLen, l; gboolean iOK; t_xs_sldb_node *tmpNode; @@ -136,18 +136,13 @@ iOK = TRUE; while ((linePos < tmpLen) && iOK) { xs_findnext(inLine, &linePos); + if (xs_sldb_gettime(inLine, &linePos) >= 0) tmpNode->nLengths++; else iOK = FALSE; } - if (!iOK) { - xs_error("Invalid sub-tune length.\n"); - xs_sldb_node_free(tmpNode); - return NULL; - } - /* Allocate memory for lengths */ tmpNode->sLengths = (gint *) g_malloc0(tmpNode->nLengths * sizeof(gint)); if (!tmpNode->sLengths) { @@ -160,14 +155,16 @@ i = 0; linePos = savePos; iOK = TRUE; - while ((linePos < tmpLen) && iOK) { + while ((linePos < tmpLen) && (i < tmpNode->nLengths) && iOK) { xs_findnext(inLine, &linePos); - if (i < tmpNode->nLengths) { - tmpNode->sLengths[i] = xs_sldb_gettime(inLine, &linePos); - i++; - } else + l = xs_sldb_gettime(inLine, &linePos); + if (l >= 0) + tmpNode->sLengths[i] = l; + else iOK = FALSE; + + i++; } if (!iOK) { @@ -184,7 +181,7 @@ /* Read database to memory */ -gint xs_sldb_read(t_xs_sldb *db, gchar *dbFilename) +gint xs_sldb_read(t_xs_sldb *db, const gchar *dbFilename) { FILE *inFile; gchar inLine[XS_BUF_SIZE]; @@ -429,7 +426,7 @@ } t_xs_psidv2_header; -static gint xs_get_sid_hash(gchar * pcFilename, t_xs_md5hash hash) +static gint xs_get_sid_hash(const gchar *pcFilename, t_xs_md5hash hash) { FILE *inFile; t_xs_md5state inState; @@ -535,7 +532,7 @@ /* Get song lengths */ -t_xs_sldb_node *xs_sldb_get(t_xs_sldb *db, gchar *pcFilename) +t_xs_sldb_node *xs_sldb_get(t_xs_sldb *db, const gchar *pcFilename) { t_xs_sldb_node *pResult; t_xs_md5hash dbHash; @@ -612,7 +609,7 @@ } -t_xs_sldb_node *xs_songlen_get(gchar * pcFilename) +t_xs_sldb_node *xs_songlen_get(const gchar * pcFilename) { t_xs_sldb_node *pResult;