From: Max Kellermann Date: Fri, 19 Sep 2008 14:37:06 +0000 (+0200) Subject: filelist: allocate entries with g_slice_alloc() X-Git-Tag: v0.12_alpha1~217 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=20b724c08772ecef49b4db36516fc033c7517fa5;p=ncmpc.git 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. --- diff --git a/src/filelist.c b/src/filelist.c index 6cbca39..e21722e 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;