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
c47f97e1
Commit
c47f97e1
authored
Oct 07, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
song: use songvec_for_each() in songvec_print() / songvec_save()
songvec_for_each() has locking, use it instead of manually iterating over the songvec items.
parent
f0366cc8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
20 deletions
+19
-20
song_print.c
src/song_print.c
+8
-8
song_save.c
src/song_save.c
+11
-12
No files found.
src/song_print.c
View file @
c47f97e1
...
...
@@ -42,14 +42,14 @@ int song_print_info(struct client *client, Song * song)
return
0
;
}
int
songvec_print
(
struct
client
*
client
,
const
struct
songvec
*
sv
)
static
int
song_print_info_x
(
Song
*
song
,
void
*
data
)
{
int
i
;
Song
**
sp
=
sv
->
base
;
for
(
i
=
sv
->
nr
;
--
i
>=
0
;)
if
(
song_print_info
(
client
,
*
sp
++
)
<
0
)
return
-
1
;
struct
client
*
client
=
data
;
return
song_print_info
(
client
,
song
);
}
return
0
;
int
songvec_print
(
struct
client
*
client
,
const
struct
songvec
*
sv
)
{
return
songvec_for_each
(
sv
,
song_print_info_x
,
client
);
}
src/song_save.c
View file @
c47f97e1
...
...
@@ -37,28 +37,27 @@ static void song_save_url(FILE *fp, Song * song)
song
->
url
);
}
static
void
song_save
(
FILE
*
fp
,
Song
*
song
)
static
int
song_save
(
Song
*
song
,
void
*
data
)
{
FILE
*
fp
=
data
;
fprintf
(
fp
,
SONG_KEY
"%s
\n
"
,
song
->
url
);
song_save_url
(
fp
,
song
);
if
(
song
->
tag
!=
NULL
)
tag_save
(
fp
,
song
->
tag
);
fprintf
(
fp
,
SONG_MTIME
"%li
\n
"
,
(
long
)
song
->
mtime
);
return
0
;
}
void
songvec_save
(
FILE
*
fp
,
struct
songvec
*
sv
)
{
int
i
;
Song
**
sp
=
sv
->
base
;
fprintf
(
fp
,
"%s
\n
"
,
SONG_BEGIN
);
for
(
i
=
sv
->
nr
;
--
i
>=
0
;
)
{
Song
*
song
=
*
sp
++
;
fprintf
(
fp
,
"%s%s
\n
"
,
SONG_KEY
,
song
->
url
);
song_save
(
fp
,
song
);
fprintf
(
fp
,
"%s%li
\n
"
,
SONG_MTIME
,
(
long
)
song
->
mtime
);
}
songvec_for_each
(
sv
,
song_save
,
fp
);
fprintf
(
fp
,
"%s
\n
"
,
SONG_END
);
}
...
...
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