X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fsong.c;h=ab79653de061698b414220cd3a91de65a50ca416;hb=850ad87b588dd6cbb96e5558ee671f2c95cc839d;hp=2d97daf7fdb21f1907cf01a82227d763129a2da7;hpb=8135d7dbf86043fb5f4e960ef4d976e4908631f3;p=ncmpc.git diff --git a/src/song.c b/src/song.c index 2d97daf..ab79653 100644 --- a/src/song.c +++ b/src/song.c @@ -33,9 +33,15 @@ #include "song.h" #include "str_pool.h" +#define LIBMPDCLIENT_GLIB_SLICE + +#ifndef LIBMPDCLIENT_GLIB_SLICE #include +#else +#include +#endif -static void mpd_initSong(mpd_Song * song) { +static void mpd_initSong(struct mpd_song *song) { song->file = NULL; song->artist = NULL; song->album = NULL; @@ -54,7 +60,7 @@ static void mpd_initSong(mpd_Song * song) { song->id = MPD_SONG_NO_ID; } -static void mpd_finishSong(mpd_Song * song) { +static void mpd_finishSong(struct mpd_song *song) { if (song->file) str_pool_put(song->file); if (song->artist) @@ -79,21 +85,30 @@ static void mpd_finishSong(mpd_Song * song) { str_pool_put(song->comment); } -mpd_Song * mpd_newSong(void) { - mpd_Song * ret = malloc(sizeof(mpd_Song)); +struct mpd_song *mpd_newSong(void) { +#ifndef LIBMPDCLIENT_GLIB_SLICE + struct mpd_song *ret = malloc(sizeof(*ret)); +#else + struct mpd_song *ret = g_slice_new(struct mpd_song); +#endif mpd_initSong(ret); return ret; } -void mpd_freeSong(mpd_Song * song) { +void mpd_freeSong(struct mpd_song *song) { mpd_finishSong(song); + +#ifndef LIBMPDCLIENT_GLIB_SLICE free(song); +#else + g_slice_free(struct mpd_song, song); +#endif } -mpd_Song * mpd_songDup(const mpd_Song * song) { - mpd_Song * ret = mpd_newSong(); +struct mpd_song *mpd_songDup(const struct mpd_song *song) { + struct mpd_song *ret = mpd_newSong(); if (song->file) ret->file = str_pool_dup(song->file);