core/tempq: Move tempq_free() out of the deck namespace
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
bce2ba33f7
commit
06d62240bb
|
@ -77,6 +77,20 @@ struct queue *tempq_alloc(struct queue_ops *ops, unsigned int flags)
|
|||
return queue;
|
||||
}
|
||||
|
||||
void tempq_free(struct queue *queue)
|
||||
{
|
||||
std::list<TempQueue>::iterator it;
|
||||
|
||||
for (it = queue_deck.begin(); it != queue_deck.end(); it++) {
|
||||
if (&(*it) == queue) {
|
||||
queue_deck.erase(it);
|
||||
deck :: write();
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void deck :: write()
|
||||
{
|
||||
std::list<TempQueue>::iterator it;
|
||||
|
@ -98,24 +112,6 @@ void deck :: save(struct queue *queue, enum queue_flags flag)
|
|||
deck :: write();
|
||||
}
|
||||
|
||||
static void _destroy(std::list<TempQueue>::iterator &it)
|
||||
{
|
||||
queue_deck.erase(it);
|
||||
deck :: write();
|
||||
}
|
||||
|
||||
void deck :: destroy(queue *queue)
|
||||
{
|
||||
std::list<TempQueue>::iterator it;
|
||||
|
||||
for (it = queue_deck.begin(); it != queue_deck.end(); it++) {
|
||||
if (&(*it) == queue) {
|
||||
_destroy(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void deck :: move(queue *queue, unsigned int index)
|
||||
{
|
||||
unsigned int old_pos = deck :: index(queue);
|
||||
|
@ -174,7 +170,7 @@ struct track *deck :: next()
|
|||
|
||||
track = queue_next(&(*it));
|
||||
if (queue_size(&(*it)) == 0)
|
||||
_destroy(it);
|
||||
tempq_free(&(*it));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ void QueueTab :: on_move_queue(int num)
|
|||
|
||||
void QueueTab :: on_close_clicked()
|
||||
{
|
||||
deck :: destroy(tab_pq);
|
||||
tempq_free(tab_pq);
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,13 +46,6 @@ namespace deck
|
|||
void write();
|
||||
void save(struct queue *, enum queue_flags);
|
||||
|
||||
/**
|
||||
* Removes the queue from the deck.
|
||||
*
|
||||
* @param queue The queue to be removed.
|
||||
*/
|
||||
void destroy(queue *);
|
||||
|
||||
/**
|
||||
* Move the queue to a new location in the deck.
|
||||
*
|
||||
|
@ -98,4 +91,7 @@ void tempq_init(struct queue_ops *);
|
|||
/* Called to allocate a new temporary queue. */
|
||||
struct queue *tempq_alloc(struct queue_ops *, unsigned int);
|
||||
|
||||
/* Called to free a temporary queue. */
|
||||
void tempq_free(struct queue *);
|
||||
|
||||
#endif /* OCARINA_CORE_DECK_H */
|
||||
|
|
|
@ -48,8 +48,8 @@ static void test_tempq()
|
|||
test_equal(queue_has_flag(q1, Q_SAVE_SORT), true);
|
||||
test_equal(queue_has_flag(q1, Q_SAVE_FLAGS), true);
|
||||
|
||||
deck :: destroy(q0);
|
||||
deck :: destroy(q1);
|
||||
tempq_free(q0);
|
||||
tempq_free(q1);
|
||||
history_deinit();
|
||||
collection_deinit();
|
||||
playlist_deinit();
|
||||
|
@ -90,11 +90,11 @@ static void test_create_mv_destroy()
|
|||
deck :: move(q1, 2);
|
||||
test_equal(deck :: index(q1), (unsigned)2);
|
||||
|
||||
deck :: destroy(q1);
|
||||
tempq_free(q1);
|
||||
test_equal(deck :: index(q1), (unsigned)3);
|
||||
test_equal(deck :: index(q2), (unsigned)2);
|
||||
|
||||
deck :: destroy(q2);
|
||||
tempq_free(q2);
|
||||
test_equal(deck :: index(q2), (unsigned)2);
|
||||
|
||||
test_equal(deck :: get(3), Q_NULL);
|
||||
|
|
Loading…
Reference in New Issue