[engine] Remove two replace functions from KvpValue

These were not used outside a test.

And that test was not leak free, as a result of the functions not doing
what they are supposed to do when the current value is not of the type
that is expected. (NULL is returned, but the value is not replaced)
This commit is contained in:
Maarten Bosmans 2023-03-16 22:08:10 +01:00
parent bd94965d9b
commit 35aeed45ec
3 changed files with 0 additions and 49 deletions

View File

@ -99,26 +99,6 @@ KvpValueImpl::get_type() const noexcept
return KvpValue::Type::INVALID;
}
KvpFrame *
KvpValueImpl::replace_frame_nc (KvpFrame * new_value) noexcept
{
if (datastore.type() != type_id<KvpFrame *>())
return {};
auto ret = boost::get<KvpFrame *>(datastore);
datastore = new_value;
return ret;
}
GList *
KvpValueImpl::replace_glist_nc (GList * new_value) noexcept
{
if (datastore.type() != type_id<GList *>())
return {};
auto ret = boost::get<GList *>(datastore);
datastore = new_value;
return ret;
}
struct to_string_visitor : boost::static_visitor<void>
{
std::ostringstream & output;

View File

@ -100,22 +100,6 @@ struct KvpValueImpl
*/
~KvpValueImpl() noexcept;
/**
* Replaces the frame within this KvpValueImpl.
*
* If this KvpValueImpl doesn't contain a KvpFrame, nullptr
* is returned. Otherwise, the old KvpFrame * is returned.
*/
KvpFrame * replace_frame_nc (KvpFrame *) noexcept;
/**
* Replaces the glist within this KvpValueImpl.
*
* If this KvpValueImpl doesn't contain a GList, nullptr
* is returned. Otherwise, the old GList * is returned.
*/
GList * replace_glist_nc (GList *) noexcept;
/**
* Adds another value to this KvpValueImpl.
*

View File

@ -30,19 +30,6 @@
#include <memory>
#include <gtest/gtest.h>
TEST (KvpValueTest, Replace_Frame)
{
auto f1 = new KvpFrameImpl;
std::unique_ptr<KvpValueImpl> v1 {new KvpValueImpl {f1}};
auto f2 = new KvpFrameImpl;
EXPECT_EQ (f1, v1->replace_frame_nc (f2));
v1->set (5.2);
/*f1 and f2 should be deleted now*/
f1 = new KvpFrameImpl;
EXPECT_EQ (nullptr, v1->replace_frame_nc (f1));
delete f1;
}
TEST (KvpValueTest, Equality)
{
std::unique_ptr<KvpValueImpl> v1 {new KvpValueImpl { (int64_t)1}};