summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ac9b642)
raw | patch | inline | side by side (parent: ac9b642)
author | Max Kellermann <max@duempel.org> | |
Tue, 16 Sep 2008 17:11:39 +0000 (19:11 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 16 Sep 2008 17:11:39 +0000 (19:11 +0200) |
Since we compile ncmpc with glib, we can use its slice allocator for
efficient song allocation. I have added a way to disable this with a
macro.
efficient song allocation. I have added a way to disable this with a
macro.
src/song.c | patch | blob | history |
diff --git a/src/song.c b/src/song.c
index 9090f8489c267e5cc5ca3c8b1bbd38422c3e326d..ab79653de061698b414220cd3a91de65a50ca416 100644 (file)
--- a/src/song.c
+++ b/src/song.c
#include "song.h"
#include "str_pool.h"
+#define LIBMPDCLIENT_GLIB_SLICE
+
+#ifndef LIBMPDCLIENT_GLIB_SLICE
#include <stdlib.h>
+#else
+#include <glib.h>
+#endif
static void mpd_initSong(struct mpd_song *song) {
song->file = NULL;
}
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);
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
}
struct mpd_song *mpd_songDup(const struct mpd_song *song) {