aboutsummaryrefslogtreecommitdiffstats
path: root/src/Queue.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-04 20:50:00 +0100
committerMax Kellermann <max@duempel.org>2013-01-04 22:12:33 +0100
commit05c91082e3de0b0078c26ddb9da68fd00da8c90e (patch)
tree7f1ef3988b787ab3e1e07e0147fabf94963495a5 /src/Queue.cxx
parent7267558ba1cba9338c78b41d11e2eadef6bb515b (diff)
downloadmpd-05c91082e3de0b0078c26ddb9da68fd00da8c90e.tar.gz
mpd-05c91082e3de0b0078c26ddb9da68fd00da8c90e.tar.xz
mpd-05c91082e3de0b0078c26ddb9da68fd00da8c90e.zip
playlist: convert to C++
Diffstat (limited to '')
-rw-r--r--src/Queue.cxx (renamed from src/queue.c)30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/queue.c b/src/Queue.cxx
index 098cbcce9..485ffb1cc 100644
--- a/src/queue.c
+++ b/src/Queue.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,7 +18,7 @@
*/
#include "config.h"
-#include "queue.h"
+#include "Queue.hxx"
#include "song.h"
#include <stdlib.h>
@@ -102,12 +102,11 @@ queue_append(struct queue *queue, struct song *song, uint8_t priority)
assert(!queue_is_full(queue));
- queue->items[queue->length] = (struct queue_item){
- .song = song_dup_detached(song),
- .id = id,
- .version = queue->version,
- .priority = priority,
- };
+ auto &item = queue->items[queue->length];
+ item.song = song_dup_detached(song);
+ item.id = id;
+ item.version = queue->version;
+ item.priority = priority;
queue->order[queue->length] = queue->length;
queue->id_to_position[id] = queue->length;
@@ -313,10 +312,11 @@ queue_init(struct queue *queue, unsigned max_length)
queue->consume = false;
queue->items = g_new(struct queue_item, max_length);
- queue->order = g_malloc(sizeof(queue->order[0]) *
- max_length);
- queue->id_to_position = g_malloc(sizeof(queue->id_to_position[0]) *
- max_length * QUEUE_HASH_MULT);
+ queue->order = (unsigned *)
+ g_malloc(sizeof(queue->order[0]) * max_length);
+ queue->id_to_position = (int *)
+ g_malloc(sizeof(queue->id_to_position[0]) *
+ max_length * QUEUE_HASH_MULT);
for (unsigned i = 0; i < max_length * QUEUE_HASH_MULT; ++i)
queue->id_to_position[i] = -1;
@@ -355,9 +355,9 @@ static gint
queue_item_compare_order_priority(gconstpointer av, gconstpointer bv,
gpointer user_data)
{
- const struct queue *queue = user_data;
- const unsigned *const ap = av;
- const unsigned *const bp = bv;
+ const struct queue *queue = (const struct queue *)user_data;
+ const unsigned *const ap = (const unsigned *)av;
+ const unsigned *const bp = (const unsigned *)bv;
assert(ap >= queue->order && ap < queue->order + queue->length);
assert(bp >= queue->order && bp < queue->order + queue->length);
uint8_t a = queue->items[*ap].priority;