From a0457d77f360d358efcde5e7449d70a513c42cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Higor=20Eur=C3=ADpedes?= Date: Thu, 11 Jun 2015 10:04:35 -0300 Subject: [PATCH] (playlist) Add content_playlist_qsort() --- playlist.c | 6 ++++++ playlist.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/playlist.c b/playlist.c index 26040b9805..3387962065 100644 --- a/playlist.c +++ b/playlist.c @@ -402,3 +402,9 @@ error: content_playlist_free(playlist); return NULL; } + +void content_playlist_qsort(content_playlist_t *playlist, content_playlist_sort_fun_t *fn) +{ + qsort(playlist->entries, playlist->size, sizeof(content_playlist_entry_t), + (int (*)(const void *, const void *))fn); +} diff --git a/playlist.h b/playlist.h index b55ef2aae5..8d913d65f1 100644 --- a/playlist.h +++ b/playlist.h @@ -43,6 +43,9 @@ typedef struct content_playlist char *conf_path; } content_playlist_t; +typedef int (content_playlist_sort_fun_t)(const content_playlist_entry_t *a, + const content_playlist_entry_t *b); + /** * content_playlist_init: * @path : Path to playlist contents file. @@ -126,6 +129,8 @@ void content_playlist_get_index_by_path(content_playlist_t *playlist, void content_playlist_write_file(content_playlist_t *playlist); +void content_playlist_qsort(content_playlist_t *playlist, content_playlist_sort_fun_t *fn); + #ifdef __cplusplus } #endif