diff --git a/zathura/database-plain.c b/zathura/database-plain.c index eede8d8..a3dad91 100644 --- a/zathura/database-plain.c +++ b/zathura/database-plain.c @@ -397,9 +397,7 @@ plain_load_bookmarks(zathura_database_t* db, const char* file) return NULL; } - girara_list_t* result = girara_sorted_list_new2((girara_compare_function_t) - zathura_bookmarks_compare, (girara_free_function_t) - zathura_bookmark_free); + girara_list_t* result = bookmarks_list_new(); gsize num_keys; char** keys = g_key_file_get_keys(priv->bookmarks, name, &num_keys, NULL); diff --git a/zathura/database-sqlite.c b/zathura/database-sqlite.c index 02ff490..9fddb29 100644 --- a/zathura/database-sqlite.c +++ b/zathura/database-sqlite.c @@ -471,8 +471,7 @@ sqlite_load_bookmarks(zathura_database_t* db, const char* file) return NULL; } - girara_list_t* result = girara_sorted_list_new2((girara_compare_function_t) zathura_bookmarks_compare, - (girara_free_function_t) zathura_bookmark_free); + girara_list_t* result = bookmarks_list_new(); if (result == NULL) { sqlite3_finalize(stmt); return NULL; diff --git a/zathura/database.c b/zathura/database.c index 4b52e95..224efd9 100644 --- a/zathura/database.c +++ b/zathura/database.c @@ -76,3 +76,24 @@ zathura_db_get_recent_files(zathura_database_t* db, int max, const char* basepat return ZATHURA_DATABASE_GET_INTERFACE(db)->get_recent_files(db, max, basepath); } + +static int +bookmarks_compare(const void* l, const void* r) +{ + const zathura_bookmark_t* lhs = l; + const zathura_bookmark_t* rhs = r; + + return zathura_bookmarks_compare(lhs, rhs); +} + +static void +bookmarks_free(void* p) +{ + zathura_bookmark_t* bookmark = p; + zathura_bookmark_free(bookmark); +} + +girara_list_t* bookmarks_list_new(void) +{ + return girara_sorted_list_new2(bookmarks_compare, bookmarks_free); +} diff --git a/zathura/database.h b/zathura/database.h index 1211a3d..f4698d1 100644 --- a/zathura/database.h +++ b/zathura/database.h @@ -140,5 +140,11 @@ bool zathura_db_get_fileinfo(zathura_database_t* db, const char* file, */ girara_list_t* zathura_db_get_recent_files(zathura_database_t* db, int max, const char* basepath); +/** + * Create list of bookmarks. + * @return empty list of bookmarks + */ +girara_list_t* bookmarks_list_new(void); + #endif // DATABASE_H