lottie/property: code refactoring

introduce the release() method for memory freeing.
This method can be used for any demands.
This commit is contained in:
Hermet Park 2024-03-21 15:05:36 +09:00
parent 727b699223
commit 3cb8c4311d

View file

@ -215,8 +215,14 @@ struct LottieGenericProperty : LottieProperty
T value;
LottieGenericProperty(T v) : value(v) {}
LottieGenericProperty() {}
~LottieGenericProperty()
{
release();
}
void release()
{
delete(frames);
}
@ -271,11 +277,17 @@ struct LottiePathSet : LottieProperty
PathSet value;
~LottiePathSet()
{
release();
}
void release()
{
free(value.cmds);
free(value.pts);
if (!frames) return;
for (auto p = frames->begin(); p < frames->end(); ++p) {
free((*p).value.cmds);
free((*p).value.pts);
@ -461,10 +473,11 @@ struct LottieColorStop : LottieProperty
const_cast<LottieColorStop&>(other).frames = nullptr;
} else {
value = other.value;
const_cast<LottieColorStop&>(other).value.data = nullptr;
const_cast<LottieColorStop&>(other).value = {nullptr, nullptr};
}
populated = other.populated;
count = other.count;
return *this;
}
@ -482,6 +495,11 @@ struct LottiePosition : LottieProperty
}
~LottiePosition()
{
release();
}
void release()
{
delete(frames);
}
@ -616,4 +634,4 @@ using LottieFloat = LottieGenericProperty<float>;
using LottieOpacity = LottieGenericProperty<uint8_t>;
using LottieColor = LottieGenericProperty<RGB24>;
#endif //_TVG_LOTTIE_PROPERTY_H_
#endif //_TVG_LOTTIE_PROPERTY_H_