(playlist) Add content_playlist_qsort()

This commit is contained in:
Higor Eurípedes 2015-06-11 10:04:35 -03:00
parent e66c8cdaf0
commit a0457d77f3
2 changed files with 11 additions and 0 deletions

View File

@ -402,3 +402,9 @@ error:
content_playlist_free(playlist); content_playlist_free(playlist);
return NULL; 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);
}

View File

@ -43,6 +43,9 @@ typedef struct content_playlist
char *conf_path; char *conf_path;
} content_playlist_t; } 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: * content_playlist_init:
* @path : Path to playlist contents file. * @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_write_file(content_playlist_t *playlist);
void content_playlist_qsort(content_playlist_t *playlist, content_playlist_sort_fun_t *fn);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif