Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
2bd34454
Commit
2bd34454
authored
Aug 15, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
queue: duplicate all song objects
Make sure the queue "owns" all song objects, so nobody else can free them.
parent
e96779de
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
5 deletions
+40
-5
Makefile.am
Makefile.am
+1
-0
queue.c
src/queue.c
+6
-5
FakeSong.cxx
test/FakeSong.cxx
+33
-0
No files found.
Makefile.am
View file @
2bd34454
...
...
@@ -1351,6 +1351,7 @@ test_test_pcm_LDADD = \
test_test_queue_priority_SOURCES
=
\
src/queue.c
\
test
/FakeSong.cxx
\
test
/test_queue_priority.c
test_test_queue_priority_LDADD
=
\
$(GLIB_LIBS)
...
...
src/queue.c
View file @
2bd34454
...
...
@@ -103,7 +103,7 @@ queue_append(struct queue *queue, struct song *song)
assert
(
!
queue_is_full
(
queue
));
queue
->
items
[
queue
->
length
]
=
(
struct
queue_item
){
.
song
=
song
,
.
song
=
song
_dup_detached
(
song
)
,
.
id
=
id
,
.
version
=
queue
->
version
,
.
priority
=
0
,
...
...
@@ -256,8 +256,8 @@ queue_delete(struct queue *queue, unsigned position)
assert
(
position
<
queue
->
length
);
song
=
queue_get
(
queue
,
position
);
if
(
!
song_in_database
(
song
))
song_free
(
song
);
assert
(
!
song_in_database
(
song
)
||
song_is_detached
(
song
));
song_free
(
song
);
id
=
queue_position_to_id
(
queue
,
position
);
order
=
queue_position_to_order
(
queue
,
position
);
...
...
@@ -291,8 +291,9 @@ queue_clear(struct queue *queue)
for
(
unsigned
i
=
0
;
i
<
queue
->
length
;
i
++
)
{
struct
queue_item
*
item
=
&
queue
->
items
[
i
];
if
(
!
song_in_database
(
item
->
song
))
song_free
(
item
->
song
);
assert
(
!
song_in_database
(
item
->
song
)
||
song_is_detached
(
item
->
song
));
song_free
(
item
->
song
);
queue
->
id_to_position
[
item
->
id
]
=
-
1
;
}
...
...
test/FakeSong.cxx
0 → 100644
View file @
2bd34454
/*
* Copyright (C) 2003-2012 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "song.h"
#include "directory.h"
#include "gcc.h"
#include <stdlib.h>
struct
directory
detached_root
;
struct
song
*
song_dup_detached
(
gcc_unused
const
struct
song
*
src
)
{
abort
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment