# HG changeset patch # User Matti Hamalainen # Date 1188861002 0 # Node ID dcd9d179e2172da5298c176fa5b6e91c004d82cc # Parent a50428d6cc494120a8988ad385b2a640884acdfa The reallocation function was buggy and subtune entries were not being stored at all, fixed. diff -r a50428d6cc49 -r dcd9d179e217 src/xs_stil.c --- a/src/xs_stil.c Mon Sep 03 05:43:03 2007 +0000 +++ b/src/xs_stil.c Mon Sep 03 23:10:02 2007 +0000 @@ -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]);