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;
|
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()
|
void deck :: write()
|
||||||
{
|
{
|
||||||
std::list<TempQueue>::iterator it;
|
std::list<TempQueue>::iterator it;
|
||||||
|
@ -98,24 +112,6 @@ void deck :: save(struct queue *queue, enum queue_flags flag)
|
||||||
deck :: write();
|
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)
|
void deck :: move(queue *queue, unsigned int index)
|
||||||
{
|
{
|
||||||
unsigned int old_pos = deck :: index(queue);
|
unsigned int old_pos = deck :: index(queue);
|
||||||
|
@ -174,7 +170,7 @@ struct track *deck :: next()
|
||||||
|
|
||||||
track = queue_next(&(*it));
|
track = queue_next(&(*it));
|
||||||
if (queue_size(&(*it)) == 0)
|
if (queue_size(&(*it)) == 0)
|
||||||
_destroy(it);
|
tempq_free(&(*it));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ void QueueTab :: on_move_queue(int num)
|
||||||
|
|
||||||
void QueueTab :: on_close_clicked()
|
void QueueTab :: on_close_clicked()
|
||||||
{
|
{
|
||||||
deck :: destroy(tab_pq);
|
tempq_free(tab_pq);
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,13 +46,6 @@ namespace deck
|
||||||
void write();
|
void write();
|
||||||
void save(struct queue *, enum queue_flags);
|
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.
|
* 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. */
|
/* Called to allocate a new temporary queue. */
|
||||||
struct queue *tempq_alloc(struct queue_ops *, unsigned int);
|
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 */
|
#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_SORT), true);
|
||||||
test_equal(queue_has_flag(q1, Q_SAVE_FLAGS), true);
|
test_equal(queue_has_flag(q1, Q_SAVE_FLAGS), true);
|
||||||
|
|
||||||
deck :: destroy(q0);
|
tempq_free(q0);
|
||||||
deck :: destroy(q1);
|
tempq_free(q1);
|
||||||
history_deinit();
|
history_deinit();
|
||||||
collection_deinit();
|
collection_deinit();
|
||||||
playlist_deinit();
|
playlist_deinit();
|
||||||
|
@ -90,11 +90,11 @@ static void test_create_mv_destroy()
|
||||||
deck :: move(q1, 2);
|
deck :: move(q1, 2);
|
||||||
test_equal(deck :: index(q1), (unsigned)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(q1), (unsigned)3);
|
||||||
test_equal(deck :: index(q2), (unsigned)2);
|
test_equal(deck :: index(q2), (unsigned)2);
|
||||||
|
|
||||||
deck :: destroy(q2);
|
tempq_free(q2);
|
||||||
test_equal(deck :: index(q2), (unsigned)2);
|
test_equal(deck :: index(q2), (unsigned)2);
|
||||||
|
|
||||||
test_equal(deck :: get(3), Q_NULL);
|
test_equal(deck :: get(3), Q_NULL);
|
||||||
|
|
Loading…
Reference in New Issue