From 405ff0cf880f737ea68260a8e205fed809ccef8b Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 22 Oct 2015 13:06:12 -0400 Subject: [PATCH] core/tags/artist: Move artist_db_init() out of the tags namespace And add the function artist_db_deinit(). Signed-off-by: Anna Schumaker --- core/tags/artist.cpp | 7 ++++++- core/tags/tags.cpp | 2 +- include/core/tags/artist.h | 10 ++++------ tests/core/tags/artist.cpp | 3 ++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/core/tags/artist.cpp b/core/tags/artist.cpp index af0aadb3..487a05ce 100644 --- a/core/tags/artist.cpp +++ b/core/tags/artist.cpp @@ -15,12 +15,17 @@ artist :: artist(const std::string &name) } -void tags :: init_artist_db() +void artist_db_init() { db_init(&artist_db, "artist.db", true); db_load(&artist_db); } +void artist_db_deinit() +{ + db_deinit(&artist_db); +} + struct artist *artist_find(const std::string &name) { return db_find(&artist_db, name.c_str()); diff --git a/core/tags/tags.cpp b/core/tags/tags.cpp index 210160fd..4ee81e36 100644 --- a/core/tags/tags.cpp +++ b/core/tags/tags.cpp @@ -11,7 +11,7 @@ void tags :: init() { album_db_init(); - tags :: init_artist_db(); + artist_db_init(); tags :: init_genre_db(); tags :: init_library_db(); tags :: init_track_db(); diff --git a/include/core/tags/artist.h b/include/core/tags/artist.h index c5817e1a..d8e41ba3 100644 --- a/include/core/tags/artist.h +++ b/include/core/tags/artist.h @@ -21,14 +21,12 @@ struct artist : public GenericTag { artist(const std::string &); }; -namespace tags -{ - /** Called to read the artist_db from disk. */ - void init_artist_db(); - -} /* Namespace: tags */ +/* Called to initialize the artist database. */ +void artist_db_init(); +/* Called to clean up the artist database. */ +void artist_db_deinit(); /* Called to find an artist tag by name. */ struct artist *artist_find(const std::string &); diff --git a/tests/core/tags/artist.cpp b/tests/core/tags/artist.cpp index c4590b48..af7097a3 100644 --- a/tests/core/tags/artist.cpp +++ b/tests/core/tags/artist.cpp @@ -66,7 +66,7 @@ static void test_artist_db() database artist_db; struct artist *artist; - tags :: init_artist_db(); + artist_db_init(); artist = artist_find("Koji Kondo"); test_verify_koji(artist); @@ -80,6 +80,7 @@ static void test_artist_db() test_equal(artist_db.db_size, 1); db_deinit(&artist_db); + artist_db_deinit(); } DECLARE_UNIT_TESTS(