aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/songvec.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/songvec.c b/src/songvec.c
index ce04a4373..3d512e917 100644
--- a/src/songvec.c
+++ b/src/songvec.c
@@ -48,10 +48,12 @@ int songvec_delete(struct songvec *sv, const struct mpd_song *del)
for (i = sv->nr; --i >= 0; ) {
if (sv->base[i] != del)
continue;
- /* we _don't_ call freeSong() here */
+ /* we _don't_ call song_free() here */
if (!--sv->nr) {
+ pthread_mutex_unlock(&nr_lock);
free(sv->base);
sv->base = NULL;
+ return i;
} else {
memmove(&sv->base[i], &sv->base[i + 1],
(sv->nr - i + 1) * sizeof(struct mpd_song *));
@@ -76,12 +78,12 @@ void songvec_add(struct songvec *sv, struct mpd_song *add)
void songvec_destroy(struct songvec *sv)
{
pthread_mutex_lock(&nr_lock);
+ sv->nr = 0;
+ pthread_mutex_unlock(&nr_lock);
if (sv->base) {
free(sv->base);
sv->base = NULL;
}
- sv->nr = 0;
- pthread_mutex_unlock(&nr_lock);
}
int songvec_for_each(const struct songvec *sv,