aboutsummaryrefslogtreecommitdiffstats
path: root/src/tree.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2006-08-01 03:29:13 +0000
committerWarren Dukes <warren.dukes@gmail.com>2006-08-01 03:29:13 +0000
commit42390c5e3b90d9fd32fe227f4eb8501eafc27a23 (patch)
tree623d1587630a12b43a7a9f83e8367f7989544866 /src/tree.c
parent6f695b8d74d6be4266d6631d1e3650ef2f8e7851 (diff)
downloadmpd-42390c5e3b90d9fd32fe227f4eb8501eafc27a23.tar.gz
mpd-42390c5e3b90d9fd32fe227f4eb8501eafc27a23.tar.xz
mpd-42390c5e3b90d9fd32fe227f4eb8501eafc27a23.zip
fix a bug when deleting songs and CHILDREN_PER_NODE > 3
git-svn-id: https://svn.musicpd.org/mpd/trunk@4507 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/tree.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/tree.c b/src/tree.c
index 52fb2c88a..c3b2bdd71 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -384,12 +384,10 @@ _DeleteAt(TreeIterator * iter)
void * dataToFree = *data;
{
- TreeNode * child = NULL;
-
// find the least greater than data to fill the whole!
if (node->children[pos+1])
{
- child = node->children[++pos];
+ TreeNode * child = node->children[++pos];
while (child->children[0])
{
pos = 0;
@@ -403,7 +401,7 @@ _DeleteAt(TreeIterator * iter)
// or the greatest lesser than data to fill the whole!
else if (node->children[pos])
{
- child = node->children[pos];
+ TreeNode * child = node->children[pos];
while (child->children[child->dataCount])
{
pos = child->dataCount;
@@ -427,12 +425,12 @@ _DeleteAt(TreeIterator * iter)
// move data nodes over, we're at a leaf node, so we can ignore
// children
- int i = --node->dataCount;
- for (; data != &(node->data[i]); i--)
+ int i = data - node->data;;
+ for (; i < node->dataCount-1; i++)
{
- node->data[i-1] = node->data[i];
+ node->data[i] = node->data[i+1];
}
- node->data[node->dataCount] = NULL;
+ node->data[--node->dataCount] = NULL;
// merge the nodes from the bottom up which have too few data
while (node->dataCount < (CHILDREN_PER_NODE/2))