Mercurial > hg > xmms-sid
comparison src/xs_stil.c @ 429:a991d1fe7e94
Bugfixes
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 01 Jan 2007 08:09:00 +0000 |
parents | faf12767a6f1 |
children | 60eedde4c44f |
comparison
equal
deleted
inserted
replaced
428:33c3bb80d2a5 | 429:a991d1fe7e94 |
---|---|
32 /* Database handling functions | 32 /* Database handling functions |
33 */ | 33 */ |
34 static gboolean xs_stildb_node_realloc(t_xs_stil_node *pNode, gint nsubTunes) | 34 static gboolean xs_stildb_node_realloc(t_xs_stil_node *pNode, gint nsubTunes) |
35 { | 35 { |
36 if (!pNode) return FALSE; | 36 if (!pNode) return FALSE; |
37 | 37 |
38 /* Re-allocate subTune structure if needed */ | 38 /* Re-allocate subTune structure if needed */ |
39 if (nsubTunes >= pNode->nsubTunes) { | 39 if (nsubTunes >= pNode->nsubTunes) { |
40 pNode->subTunes = | 40 pNode->subTunes = |
41 (t_xs_stil_subnode **) g_realloc(pNode->subTunes, | 41 (t_xs_stil_subnode **) g_realloc(pNode->subTunes, |
42 (nsubTunes + 1) * sizeof(t_xs_stil_subnode **)); | 42 (nsubTunes + 1) * sizeof(t_xs_stil_subnode **)); |
46 return FALSE; | 46 return FALSE; |
47 } | 47 } |
48 | 48 |
49 /* Clear the newly allocated memory */ | 49 /* Clear the newly allocated memory */ |
50 xs_memset(&(pNode->subTunes[pNode->nsubTunes]), 0, | 50 xs_memset(&(pNode->subTunes[pNode->nsubTunes]), 0, |
51 (nsubTunes + 1 - pNode->nsubTunes) * | 51 (nsubTunes - pNode->nsubTunes + 1) * sizeof(t_xs_stil_subnode **)); |
52 sizeof(t_xs_stil_subnode **)); | |
53 | 52 |
54 pNode->nsubTunes = nsubTunes + 1; | 53 pNode->nsubTunes = nsubTunes; |
55 } | 54 } |
56 | 55 |
57 /* Allocate memory for subTune */ | 56 /* Allocate memory for subTune */ |
58 if (!pNode->subTunes[nsubTunes]) { | 57 if (!pNode->subTunes[nsubTunes]) { |
59 pNode->subTunes[nsubTunes] = (t_xs_stil_subnode *) | 58 pNode->subTunes[nsubTunes] = (t_xs_stil_subnode *) |
74 gint i; | 73 gint i; |
75 t_xs_stil_subnode *pSub; | 74 t_xs_stil_subnode *pSub; |
76 | 75 |
77 if (pNode) { | 76 if (pNode) { |
78 /* Free subtune information */ | 77 /* Free subtune information */ |
79 for (i = 0; i < pNode->nsubTunes; i++) { | 78 for (i = 0; i <= pNode->nsubTunes; i++) { |
80 pSub = pNode->subTunes[i]; | 79 pSub = pNode->subTunes[i]; |
81 if (pSub) { | 80 if (pSub) { |
82 g_free(pSub->pName); | 81 g_free(pSub->pName); |
83 g_free(pSub->pAuthor); | 82 g_free(pSub->pAuthor); |
84 g_free(pSub->pInfo); | 83 g_free(pSub->pInfo); |