From 20b724c08772ecef49b4db36516fc033c7517fa5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 19 Sep 2008 16:37:06 +0200 Subject: filelist: allocate entries with g_slice_alloc() In this case, slices are faster. Also fix a memory leak in filelist_prepend() which I simply forgot about in the last patch set. --- src/filelist.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/filelist.c b/src/filelist.c index 6cbca39df..e21722ec4 100644 --- a/src/filelist.c +++ b/src/filelist.c @@ -57,7 +57,7 @@ filelist_free(struct filelist *filelist) struct filelist_entry * filelist_append(struct filelist *filelist, struct mpd_InfoEntity *entity) { - struct filelist_entry *entry = g_malloc(sizeof(*entry)); + struct filelist_entry *entry = g_slice_alloc(sizeof(*entry)); entry->flags = 0; entry->entity = entity; @@ -70,14 +70,12 @@ filelist_append(struct filelist *filelist, struct mpd_InfoEntity *entity) struct filelist_entry * filelist_prepend(struct filelist *filelist, struct mpd_InfoEntity *entity) { - struct filelist_entry *entry = g_malloc(sizeof(*entry)); + struct filelist_entry *entry = filelist_append(filelist, entity); /* this is very slow, but we should optimize screen_artist.c later so that this function can be removed, so I'm not in the mood to implement something better here */ - entry = filelist_append(filelist, entity); - if (!filelist_is_empty(filelist)) { guint i; -- cgit v1.2.3