From abe12bac64189276a186b5f510a36ccc73473f9b Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 24 Sep 2015 11:18:48 -0400 Subject: [PATCH] core/tags/album: Move album_db_init() out of the tags namespace And add the function album_db_deinit(). Signed-off-by: Anna Schumaker --- core/tags/album.cpp | 7 ++++++- core/tags/tags.cpp | 2 +- include/core/tags/album.h | 10 ++++------ tests/core/tags/album.cpp | 3 ++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/core/tags/album.cpp b/core/tags/album.cpp index ba9c18b6..00c629f1 100644 --- a/core/tags/album.cpp +++ b/core/tags/album.cpp @@ -63,12 +63,17 @@ unsigned int album :: year() } -void tags :: init_album_db() +void album_db_init() { db_init(&album_db, "album.db", true); db_load(&album_db); } +void album_db_deinit() +{ + db_deinit(&album_db); +} + struct album *album_find(const std::string &name, unsigned int year) { return db_find(&album_db, make_key(name, year).c_str()); diff --git a/core/tags/tags.cpp b/core/tags/tags.cpp index 83adbd4c..210160fd 100644 --- a/core/tags/tags.cpp +++ b/core/tags/tags.cpp @@ -10,7 +10,7 @@ void tags :: init() { - tags :: init_album_db(); + album_db_init(); tags :: init_artist_db(); tags :: init_genre_db(); tags :: init_library_db(); diff --git a/include/core/tags/album.h b/include/core/tags/album.h index 7ea8db98..c237a577 100644 --- a/include/core/tags/album.h +++ b/include/core/tags/album.h @@ -62,14 +62,12 @@ struct album : public GenericTag { unsigned int year(); }; -namespace tags -{ - /** Called to read the album_db from disk. */ - void init_album_db(); - -} /* Namespace: tags */ +/* Called to initialize the album database. */ +void album_db_init(); +/* Called to clean up the album database. */ +void album_db_deinit(); /* Called to find an album tag by name and year. */ struct album *album_find(const std::string &, unsigned int); diff --git a/tests/core/tags/album.cpp b/tests/core/tags/album.cpp index b6c44b7b..f5da1cab 100644 --- a/tests/core/tags/album.cpp +++ b/tests/core/tags/album.cpp @@ -65,7 +65,7 @@ static void test_album_db() database album_db; struct album *album; - tags :: init_album_db(); + album_db_init(); album = album_find("Hyrule Symphony", 1998); test_verify_hyrule(album); @@ -79,6 +79,7 @@ static void test_album_db() test_equal(album_db.db_size, 1); db_deinit(&album_db); + album_db_deinit(); } DECLARE_UNIT_TESTS(