2 (c)2003-2006 by Warren Dukes (warren.dukes@gmail.com)
3 This project's homepage is: http://www.musicpd.org
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
9 - Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
12 - Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 - Neither the name of the Music Player Daemon nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
24 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #define LIBMPDCLIENT_GLIB_SLICE
38 #ifndef LIBMPDCLIENT_GLIB_SLICE
44 static void mpd_initSong(struct mpd_song
*song
) {
54 song
->composer
= NULL
;
58 song
->time
= MPD_SONG_NO_TIME
;
59 song
->pos
= MPD_SONG_NO_NUM
;
60 song
->id
= MPD_SONG_NO_ID
;
63 static void mpd_finishSong(struct mpd_song
*song
) {
65 str_pool_put(song
->file
);
67 str_pool_put(song
->artist
);
69 str_pool_put(song
->album
);
71 str_pool_put(song
->title
);
73 str_pool_put(song
->track
);
75 str_pool_put(song
->name
);
77 str_pool_put(song
->date
);
79 str_pool_put(song
->genre
);
81 str_pool_put(song
->composer
);
83 str_pool_put(song
->disc
);
85 str_pool_put(song
->comment
);
88 struct mpd_song
*mpd_newSong(void) {
89 #ifndef LIBMPDCLIENT_GLIB_SLICE
90 struct mpd_song
*ret
= malloc(sizeof(*ret
));
92 struct mpd_song
*ret
= g_slice_new(struct mpd_song
);
100 void mpd_freeSong(struct mpd_song
*song
) {
101 mpd_finishSong(song
);
103 #ifndef LIBMPDCLIENT_GLIB_SLICE
106 g_slice_free(struct mpd_song
, song
);
110 struct mpd_song
*mpd_songDup(const struct mpd_song
*song
) {
111 struct mpd_song
*ret
= mpd_newSong();
114 ret
->file
= str_pool_dup(song
->file
);
116 ret
->artist
= str_pool_dup(song
->artist
);
118 ret
->album
= str_pool_dup(song
->album
);
120 ret
->title
= str_pool_dup(song
->title
);
122 ret
->track
= str_pool_dup(song
->track
);
124 ret
->name
= str_pool_dup(song
->name
);
126 ret
->date
= str_pool_dup(song
->date
);
128 ret
->genre
= str_pool_dup(song
->genre
);
130 ret
->composer
= str_pool_dup(song
->composer
);
132 ret
->disc
= str_pool_dup(song
->disc
);
134 ret
->comment
= str_pool_dup(song
->comment
);
136 ret
->time
= song
->time
;
137 ret
->pos
= song
->pos
;