From 5aab145227c0870e4437050c72aa70fc8d18ee80 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Fri, 11 Dec 2015 23:26:03 +0000 Subject: [PATCH] Remove API's loot_cleanup() function It's no longer required as the message string is not manually allocated, its lifetime is tied to that of the library. --- include/loot/api.h | 5 ----- src/api/api.cpp | 5 ----- src/tests/api/test_api.h | 25 ------------------------- 3 files changed, 35 deletions(-) diff --git a/include/loot/api.h b/include/loot/api.h index 9056cd1b..73e47db6 100644 --- a/include/loot/api.h +++ b/include/loot/api.h @@ -309,11 +309,6 @@ extern "C" */ LOOT_API unsigned int loot_get_error_message(const char ** const message); - /** - * @brief Frees the memory allocated to the last error details string. - */ - LOOT_API void loot_cleanup(); - /**@}*/ /**********************************************************************//** * @name Version Functions diff --git a/src/api/api.cpp b/src/api/api.cpp index 5a8d2f83..5a41af2e 100644 --- a/src/api/api.cpp +++ b/src/api/api.cpp @@ -269,11 +269,6 @@ LOOT_API unsigned int loot_get_error_message(const char ** const message) { return loot_ok; } -// Frees memory allocated to error string. -LOOT_API void loot_cleanup() { - extMessageStr.clear(); -} - ////////////////////////////// // Version Functions ////////////////////////////// diff --git a/src/tests/api/test_api.h b/src/tests/api/test_api.h index 32fa1042..06efc027 100644 --- a/src/tests/api/test_api.h +++ b/src/tests/api/test_api.h @@ -76,31 +76,6 @@ TEST(GetErrorMessage, HandlesInputCorrectly) { ASSERT_STREQ("Null message pointer passed.", error); } -TEST(Cleanup, CleansUpAfterError) { - // First generate an error. - EXPECT_EQ(loot_error_invalid_args, loot_get_error_message(NULL)); - - // Check that the error message is non-null. - const char * error; - EXPECT_EQ(loot_ok, loot_get_error_message(&error)); - ASSERT_STREQ("Null message pointer passed.", error); - - ASSERT_NO_THROW(loot_cleanup()); - - // Now check that the error message pointer is null. - error = nullptr; - EXPECT_EQ(loot_ok, loot_get_error_message(&error)); - EXPECT_EQ(nullptr, error); -} - -TEST(Cleanup, HandlesNoError) { - ASSERT_NO_THROW(loot_cleanup()); - - const char * error = nullptr; - EXPECT_EQ(loot_ok, loot_get_error_message(&error)); - EXPECT_EQ(nullptr, error); -} - TEST_F(OblivionTest, CreateDbHandlesValidInputs) { EXPECT_EQ(loot_ok, loot_create_db(&db, loot_game_tes4, dataPath.parent_path().string().c_str(), localPath.string().c_str())); ASSERT_NO_THROW(loot_destroy_db(db));