feat(thorvg): use LVGL's malloc/realloc/zalloc/free (#7772)
This commit is contained in:
committed by
GitHub
parent
2bf2ab46ce
commit
fc5c156385
@@ -7,17 +7,17 @@
|
||||
*/
|
||||
void lv_example_lottie_1(void)
|
||||
{
|
||||
extern const uint8_t lv_example_lottie_approve[];
|
||||
extern const size_t lv_example_lottie_approve_size;
|
||||
extern const uint8_t rain[];
|
||||
extern const size_t rain_size;
|
||||
|
||||
lv_obj_t * lottie = lv_lottie_create(lv_screen_active());
|
||||
lv_lottie_set_src_data(lottie, lv_example_lottie_approve, lv_example_lottie_approve_size);
|
||||
lv_lottie_set_src_data(lottie, rain, rain_size);
|
||||
|
||||
#if LV_DRAW_BUF_ALIGN == 4 && LV_DRAW_BUF_STRIDE_ALIGN == 1
|
||||
/*If there are no special requirements, just declare a buffer
|
||||
x4 because the Lottie is rendered in ARGB8888 format*/
|
||||
static uint8_t buf[64 * 64 * 4];
|
||||
lv_lottie_set_buffer(lottie, 64, 64, buf);
|
||||
static uint8_t buf[364 * 364 * 4];
|
||||
lv_lottie_set_buffer(lottie, 364, 364, buf);
|
||||
#else
|
||||
/*For GPUs and special alignment/strid setting use a draw_buf instead*/
|
||||
LV_DRAW_BUF_DEFINE(draw_buf, 64, 64, LV_COLOR_FORMAT_ARGB8888);
|
||||
|
||||
@@ -494,7 +494,7 @@ void lv_draw_sw_vector(lv_draw_task_t * t, const lv_draw_vector_task_dsc_t * dsc
|
||||
}
|
||||
|
||||
Tvg_Canvas * canvas = tvg_swcanvas_create();
|
||||
tvg_swcanvas_set_target(canvas, buf, stride / 4, width, height, TVG_COLORSPACE_ARGB8888);
|
||||
tvg_swcanvas_set_target(canvas, buf, stride / 4, width, height, TVG_COLORSPACE_ARGB8888S);
|
||||
|
||||
_tvg_rect rc;
|
||||
lv_area_to_tvg(&rc, &t->clip_area);
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
#include "../../../misc/lv_assert.h"
|
||||
|
||||
RAPIDJSON_NAMESPACE_BEGIN
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -84,10 +86,13 @@ class CrtAllocator {
|
||||
public:
|
||||
static const bool kNeedFree = true;
|
||||
void* Malloc(size_t size) {
|
||||
if (size) // behavior of malloc(0) is implementation defined.
|
||||
return RAPIDJSON_MALLOC(size);
|
||||
else
|
||||
if (size) { // behavior of malloc(0) is implementation defined.
|
||||
void * p = RAPIDJSON_MALLOC(size);
|
||||
LV_ASSERT_MALLOC(p);
|
||||
return p;
|
||||
} else {
|
||||
return NULL; // standardize to returning NULL.
|
||||
}
|
||||
}
|
||||
void* Realloc(void* originalPtr, size_t originalSize, size_t newSize) {
|
||||
(void)originalSize;
|
||||
@@ -95,7 +100,9 @@ public:
|
||||
RAPIDJSON_FREE(originalPtr);
|
||||
return NULL;
|
||||
}
|
||||
return RAPIDJSON_REALLOC(originalPtr, newSize);
|
||||
void * p = RAPIDJSON_REALLOC(originalPtr, newSize);
|
||||
LV_ASSERT_MALLOC(p);
|
||||
return p;
|
||||
}
|
||||
static void Free(void *ptr) RAPIDJSON_NOEXCEPT { RAPIDJSON_FREE(ptr); }
|
||||
|
||||
|
||||
@@ -690,18 +690,18 @@ RAPIDJSON_NAMESPACE_END
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// malloc/realloc/free
|
||||
|
||||
#include "../../../stdlib/lv_mem.h"
|
||||
#ifndef RAPIDJSON_MALLOC
|
||||
///! customization point for global \c malloc
|
||||
#define RAPIDJSON_MALLOC(size) std::malloc(size)
|
||||
#define RAPIDJSON_MALLOC(size) lv_malloc(size)
|
||||
#endif
|
||||
#ifndef RAPIDJSON_REALLOC
|
||||
///! customization point for global \c realloc
|
||||
#define RAPIDJSON_REALLOC(ptr, new_size) std::realloc(ptr, new_size)
|
||||
#define RAPIDJSON_REALLOC(ptr, new_size) lv_realloc(ptr, new_size)
|
||||
#endif
|
||||
#ifndef RAPIDJSON_FREE
|
||||
///! customization point for global \c free
|
||||
#define RAPIDJSON_FREE(ptr) std::free(ptr)
|
||||
#define RAPIDJSON_FREE(ptr) lv_free(ptr)
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include "../../stdlib/lv_mem.h"
|
||||
#include "../../stdlib/lv_string.h"
|
||||
#include "../../misc/lv_assert.h"
|
||||
|
||||
#ifdef TVG_API
|
||||
#undef TVG_API
|
||||
@@ -1056,7 +1059,7 @@ public:
|
||||
* @param[in] miterlimit The miterlimit imposes a limit on the extent of the stroke join, when the @c StrokeJoin::Miter join style is set. The default value is 4.
|
||||
*
|
||||
* @retval Result::InvalidArgument for @p miterlimit values less than zero.
|
||||
*
|
||||
*
|
||||
* @since 0.11
|
||||
*/
|
||||
Result strokeMiterlimit(float miterlimit) noexcept;
|
||||
@@ -1605,7 +1608,7 @@ public:
|
||||
*
|
||||
* @note If the font data is currently in use, it will not be immediately unloaded.
|
||||
* @see Text::load(const std::string& path)
|
||||
*
|
||||
*
|
||||
* @since 0.15
|
||||
*/
|
||||
static Result unload(const std::string& path) noexcept;
|
||||
|
||||
@@ -57,7 +57,8 @@ struct Array
|
||||
{
|
||||
if (count + 1 > reserved) {
|
||||
reserved = count + (count + 2) / 2;
|
||||
data = static_cast<T*>(realloc(data, sizeof(T) * reserved));
|
||||
data = static_cast<T*>(lv_realloc(data, sizeof(T) * reserved));
|
||||
LV_ASSERT_MALLOC(data);
|
||||
}
|
||||
data[count++] = element;
|
||||
}
|
||||
@@ -74,7 +75,8 @@ struct Array
|
||||
{
|
||||
if (size > reserved) {
|
||||
reserved = size;
|
||||
data = static_cast<T*>(realloc(data, sizeof(T) * reserved));
|
||||
data = static_cast<T*>(lv_realloc(data, sizeof(T) * reserved));
|
||||
LV_ASSERT_MALLOC(data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -141,7 +143,7 @@ struct Array
|
||||
|
||||
void reset()
|
||||
{
|
||||
free(data);
|
||||
lv_free(data);
|
||||
data = nullptr;
|
||||
count = reserved = 0;
|
||||
}
|
||||
@@ -171,7 +173,7 @@ struct Array
|
||||
|
||||
~Array()
|
||||
{
|
||||
free(data);
|
||||
lv_free(data);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -57,8 +57,7 @@
|
||||
* http://marknelson.us/1989/10/01/lzw-data-compression/
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include "thorvg.h"
|
||||
|
||||
#include <string>
|
||||
#include <memory.h>
|
||||
@@ -112,7 +111,8 @@ struct BitStreamWriter
|
||||
|
||||
uint8_t* allocBytes(const int bytesWanted, uint8_t * oldPtr, const int oldSize)
|
||||
{
|
||||
auto newMemory = static_cast<uint8_t *>(malloc(bytesWanted));
|
||||
auto newMemory = static_cast<uint8_t *>(lv_malloc(bytesWanted));
|
||||
LV_ASSERT_MALLOC(newMemory);
|
||||
memset(newMemory, 0, bytesWanted);
|
||||
|
||||
if (oldPtr) {
|
||||
@@ -349,7 +349,8 @@ uint8_t* lzwDecode(const uint8_t* compressed, uint32_t compressedSizeBytes, uint
|
||||
int firstByte = 0;
|
||||
int bytesDecoded = 0;
|
||||
int codeBitsWidth = StartBits;
|
||||
auto uncompressed = (uint8_t*) malloc(sizeof(uint8_t) * uncompressedSizeBytes);
|
||||
auto uncompressed = (uint8_t*) lv_malloc(sizeof(uint8_t) * uncompressedSizeBytes);
|
||||
LV_ASSERT_MALLOC(uncompressed);
|
||||
auto ptr = uncompressed;
|
||||
|
||||
/* We'll reconstruct the dictionary based on the bit stream codes.
|
||||
@@ -445,7 +446,8 @@ size_t b64Decode(const char* encoded, const size_t len, char** decoded)
|
||||
if (!decoded || !encoded || len == 0) return 0;
|
||||
|
||||
auto reserved = 3 * (1 + (len >> 2)) + 1;
|
||||
auto output = static_cast<char*>(malloc(reserved * sizeof(char)));
|
||||
auto output = static_cast<char*>(lv_malloc(reserved * sizeof(char)));
|
||||
LV_ASSERT_MALLOC(output);
|
||||
if (!output) return 0;
|
||||
output[reserved - 1] = '\0';
|
||||
|
||||
|
||||
@@ -103,7 +103,8 @@ Result Fill::colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept
|
||||
}
|
||||
|
||||
if (pImpl->cnt != cnt) {
|
||||
pImpl->colorStops = static_cast<ColorStop*>(realloc(pImpl->colorStops, cnt * sizeof(ColorStop)));
|
||||
pImpl->colorStops = static_cast<ColorStop*>(lv_realloc(pImpl->colorStops, cnt * sizeof(ColorStop)));
|
||||
LV_ASSERT_MALLOC(pImpl->colorStops);
|
||||
}
|
||||
|
||||
pImpl->cnt = cnt;
|
||||
@@ -138,7 +139,8 @@ FillSpread Fill::spread() const noexcept
|
||||
Result Fill::transform(const Matrix& m) noexcept
|
||||
{
|
||||
if (!pImpl->transform) {
|
||||
pImpl->transform = static_cast<Matrix*>(malloc(sizeof(Matrix)));
|
||||
pImpl->transform = static_cast<Matrix*>(lv_malloc(sizeof(Matrix)));
|
||||
LV_ASSERT_MALLOC(pImpl->transform);
|
||||
}
|
||||
*pImpl->transform = m;
|
||||
return Result::Success;
|
||||
|
||||
@@ -62,8 +62,8 @@ struct Fill::Impl
|
||||
~Impl()
|
||||
{
|
||||
delete(dup);
|
||||
free(colorStops);
|
||||
free(transform);
|
||||
lv_free(colorStops);
|
||||
lv_free(transform);
|
||||
}
|
||||
|
||||
void method(DuplicateMethod<Fill>* dup)
|
||||
@@ -78,10 +78,12 @@ struct Fill::Impl
|
||||
|
||||
ret->pImpl->cnt = cnt;
|
||||
ret->pImpl->spread = spread;
|
||||
ret->pImpl->colorStops = static_cast<ColorStop*>(malloc(sizeof(ColorStop) * cnt));
|
||||
ret->pImpl->colorStops = static_cast<ColorStop*>(lv_malloc(sizeof(ColorStop) * cnt));
|
||||
LV_ASSERT_MALLOC(ret->pImpl->colorStops);
|
||||
memcpy(ret->pImpl->colorStops, colorStops, sizeof(ColorStop) * cnt);
|
||||
if (transform) {
|
||||
ret->pImpl->transform = static_cast<Matrix*>(malloc(sizeof(Matrix)));
|
||||
ret->pImpl->transform = static_cast<Matrix*>(lv_malloc(sizeof(Matrix)));
|
||||
LV_ASSERT_MALLOC(ret->pImpl->transform);
|
||||
*ret->pImpl->transform = *transform;
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -48,7 +48,7 @@ struct LoadModule
|
||||
LoadModule(FileType type) : type(type) {}
|
||||
virtual ~LoadModule()
|
||||
{
|
||||
if (pathcache) free(hashpath);
|
||||
if (pathcache) lv_free(hashpath);
|
||||
}
|
||||
|
||||
virtual bool open(const string& path) { return false; }
|
||||
|
||||
@@ -309,7 +309,7 @@ LoadModule* LoaderMgr::loader(const string& path, bool* invalid)
|
||||
if (auto loader = _findByPath(path)) {
|
||||
if (loader->open(path)) {
|
||||
if (allowCache) {
|
||||
loader->hashpath = strdup(path.c_str());
|
||||
loader->hashpath = lv_strdup(path.c_str());
|
||||
loader->pathcache = true;
|
||||
{
|
||||
ScopedLock lock(key);
|
||||
@@ -325,7 +325,7 @@ LoadModule* LoaderMgr::loader(const string& path, bool* invalid)
|
||||
if (auto loader = _find(static_cast<FileType>(i))) {
|
||||
if (loader->open(path)) {
|
||||
if (allowCache) {
|
||||
loader->hashpath = strdup(path.c_str());
|
||||
loader->hashpath = lv_strdup(path.c_str());
|
||||
loader->pathcache = true;
|
||||
{
|
||||
ScopedLock lock(key);
|
||||
@@ -448,7 +448,7 @@ LoadModule* LoaderMgr::loader(const char* name, const char* data, uint32_t size,
|
||||
//function is dedicated for ttf loader (the only supported font loader)
|
||||
auto loader = new TtfLoader;
|
||||
if (loader->open(data, size, copy)) {
|
||||
loader->hashpath = strdup(name);
|
||||
loader->hashpath = lv_strdup(name);
|
||||
loader->pathcache = true;
|
||||
ScopedLock lock(key);
|
||||
_activeLoaders.back(loader);
|
||||
|
||||
@@ -181,7 +181,10 @@ void LottieBuilder::updateTransform(LottieGroup* parent, LottieObject** child, f
|
||||
uint8_t opacity;
|
||||
|
||||
if (parent->mergeable()) {
|
||||
if (!ctx->transform) ctx->transform = (Matrix*)malloc(sizeof(Matrix));
|
||||
if (!ctx->transform) {
|
||||
ctx->transform = (Matrix*)lv_malloc(sizeof(Matrix));
|
||||
LV_ASSERT_MALLOC(ctx->transform);
|
||||
}
|
||||
_updateTransform(transform, frameNo, false, *ctx->transform, opacity, exps);
|
||||
return;
|
||||
}
|
||||
@@ -481,7 +484,7 @@ void LottieBuilder::updateRect(LottieGroup* parent, LottieObject** child, float
|
||||
} else {
|
||||
r = std::min({r, size.x * 0.5f, size.y * 0.5f});
|
||||
}
|
||||
|
||||
|
||||
if (!ctx->repeaters.empty()) {
|
||||
auto shape = rect->pooling();
|
||||
shape->reset();
|
||||
@@ -531,7 +534,7 @@ static void _appendCircle(Shape* shape, float cx, float cy, float rx, float ry,
|
||||
points[i] *= *transform;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
shape->appendPath(commands, cmdsCnt, points, ptsCnt);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ struct RenderContext
|
||||
~RenderContext()
|
||||
{
|
||||
PP(propagator)->unref();
|
||||
free(transform);
|
||||
lv_free(transform);
|
||||
delete(roundness);
|
||||
delete(offsetPath);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,8 @@ static LottieExpressions* exps = nullptr; //singleton instance engine
|
||||
|
||||
static ExpContent* _expcontent(LottieExpression* exp, float frameNo, LottieObject* obj)
|
||||
{
|
||||
auto data = (ExpContent*)malloc(sizeof(ExpContent));
|
||||
auto data = (ExpContent*)lv_malloc(sizeof(ExpContent));
|
||||
LV_ASSERT_MALLOC(ndata);
|
||||
data->exp = exp;
|
||||
data->frameNo = frameNo;
|
||||
data->obj = obj;
|
||||
@@ -73,7 +74,7 @@ static ExpContent* _expcontent(LottieExpression* exp, float frameNo, LottieObjec
|
||||
|
||||
static void contentFree(void *native_p, struct jerry_object_native_info_t *info_p)
|
||||
{
|
||||
free(native_p);
|
||||
lv_free(native_p);
|
||||
}
|
||||
|
||||
static jerry_object_native_info_t freeCb {contentFree, 0, 0};
|
||||
@@ -84,7 +85,8 @@ static char* _name(jerry_value_t args)
|
||||
{
|
||||
auto arg0 = jerry_value_to_string(args);
|
||||
auto len = jerry_string_length(arg0);
|
||||
auto name = (jerry_char_t*)malloc(len * sizeof(jerry_char_t) + 1);
|
||||
auto name = (jerry_char_t*)lv_malloc(len * sizeof(jerry_char_t) + 1);
|
||||
LV_ASSERT_MALLOC(name);
|
||||
jerry_string_to_buffer(arg0, JERRY_ENCODING_UTF8, name, len);
|
||||
name[len] = '\0';
|
||||
jerry_value_free(arg0);
|
||||
@@ -96,7 +98,7 @@ static unsigned long _idByName(jerry_value_t args)
|
||||
{
|
||||
auto name = _name(args);
|
||||
auto id = djb2Encode(name);
|
||||
free(name);
|
||||
lv_free(name);
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -832,7 +834,7 @@ static bool _loopOutCommon(LottieExpression* exp, const jerry_value_t args[], co
|
||||
else if (!strcmp(name, EXP_PINGPONG)) exp->loop.mode = LottieExpression::LoopMode::OutPingPong;
|
||||
else if (!strcmp(name, EXP_OFFSET)) exp->loop.mode = LottieExpression::LoopMode::OutOffset;
|
||||
else if (!strcmp(name, EXP_CONTINUE)) exp->loop.mode = LottieExpression::LoopMode::OutContinue;
|
||||
free(name);
|
||||
lv_free(name);
|
||||
}
|
||||
|
||||
if (exp->loop.mode != LottieExpression::LoopMode::OutCycle && exp->loop.mode != LottieExpression::LoopMode::OutPingPong) {
|
||||
@@ -884,7 +886,7 @@ static bool _loopInCommon(LottieExpression* exp, const jerry_value_t args[], con
|
||||
else if (!strcmp(name, EXP_PINGPONG)) exp->loop.mode = LottieExpression::LoopMode::InPingPong;
|
||||
else if (!strcmp(name, EXP_OFFSET)) exp->loop.mode = LottieExpression::LoopMode::InOffset;
|
||||
else if (!strcmp(name, EXP_CONTINUE)) exp->loop.mode = LottieExpression::LoopMode::InContinue;
|
||||
free(name);
|
||||
lv_free(name);
|
||||
}
|
||||
|
||||
if (exp->loop.mode != LottieExpression::LoopMode::InCycle && exp->loop.mode != LottieExpression::LoopMode::InPingPong) {
|
||||
|
||||
@@ -130,7 +130,7 @@ float LottieInterpolator::progress(float t)
|
||||
|
||||
void LottieInterpolator::set(const char* key, Point& inTangent, Point& outTangent)
|
||||
{
|
||||
this->key = strdup(key);
|
||||
this->key = lv_strdup(key);
|
||||
this->inTangent = inTangent;
|
||||
this->outTangent = outTangent;
|
||||
|
||||
|
||||
@@ -57,10 +57,10 @@ void LottieLoader::run(unsigned tid)
|
||||
void LottieLoader::release()
|
||||
{
|
||||
if (copy) {
|
||||
free((char*)content);
|
||||
lv_free((char*)content);
|
||||
content = nullptr;
|
||||
}
|
||||
free(dirName);
|
||||
lv_free(dirName);
|
||||
dirName = nullptr;
|
||||
}
|
||||
|
||||
@@ -201,13 +201,14 @@ bool LottieLoader::header()
|
||||
bool LottieLoader::open(const char* data, uint32_t size, bool copy)
|
||||
{
|
||||
if (copy) {
|
||||
content = (char*)malloc(size + 1);
|
||||
content = (char*)lv_malloc(size + 1);
|
||||
LV_ASSERT_MALLOC(content);
|
||||
if (!content) return false;
|
||||
memcpy((char*)content, data, size);
|
||||
const_cast<char*>(content)[size] = '\0';
|
||||
} else content = data;
|
||||
|
||||
this->dirName = strdup(".");
|
||||
this->dirName = lv_strdup(".");
|
||||
|
||||
this->size = size;
|
||||
this->copy = copy;
|
||||
@@ -229,7 +230,8 @@ bool LottieLoader::open(const string& path)
|
||||
return false;
|
||||
}
|
||||
|
||||
auto content = (char*)(malloc(sizeof(char) * size + 1));
|
||||
auto content = (char*)(lv_malloc(sizeof(char) * size + 1));
|
||||
LV_ASSERT_MALLOC(content);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
auto ret = fread(content, sizeof(char), size, f);
|
||||
if (ret < size) {
|
||||
@@ -298,7 +300,7 @@ bool LottieLoader::override(const char* slot)
|
||||
//override slots
|
||||
if (slot) {
|
||||
//Copy the input data because the JSON parser will encode the data immediately.
|
||||
auto temp = strdup(slot);
|
||||
auto temp = lv_strdup(slot);
|
||||
|
||||
//parsing slot json
|
||||
LottieParser parser(temp, dirName);
|
||||
@@ -315,7 +317,7 @@ bool LottieLoader::override(const char* slot)
|
||||
}
|
||||
|
||||
if (idx < 1) success = false;
|
||||
free(temp);
|
||||
lv_free(temp);
|
||||
rebuild = overridden = success;
|
||||
//reset slots
|
||||
} else if (overridden) {
|
||||
|
||||
@@ -133,8 +133,8 @@ void LottieTextRange::range(float frameNo, float totalLen, float& start, float&
|
||||
|
||||
LottieImage::~LottieImage()
|
||||
{
|
||||
free(b64Data);
|
||||
free(mimeType);
|
||||
lv_free(b64Data);
|
||||
lv_free(mimeType);
|
||||
}
|
||||
|
||||
|
||||
@@ -423,7 +423,7 @@ LottieLayer::~LottieLayer()
|
||||
}
|
||||
|
||||
delete(transform);
|
||||
free(name);
|
||||
lv_free(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -473,13 +473,13 @@ LottieComposition::~LottieComposition()
|
||||
if (!initiated && root) delete(root->scene);
|
||||
|
||||
delete(root);
|
||||
free(version);
|
||||
free(name);
|
||||
lv_free(version);
|
||||
lv_free(name);
|
||||
|
||||
//delete interpolators
|
||||
for (auto i = interpolators.begin(); i < interpolators.end(); ++i) {
|
||||
free((*i)->key);
|
||||
free(*i);
|
||||
lv_free((*i)->key);
|
||||
lv_free(*i);
|
||||
}
|
||||
|
||||
//delete assets
|
||||
@@ -496,7 +496,7 @@ LottieComposition::~LottieComposition()
|
||||
for (auto s = slots.begin(); s < slots.end(); ++s) {
|
||||
delete(*s);
|
||||
}
|
||||
|
||||
|
||||
for (auto m = markers.begin(); m < markers.end(); ++m) {
|
||||
delete(*m);
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ struct LottieGlyph
|
||||
~LottieGlyph()
|
||||
{
|
||||
for (auto p = children.begin(); p < children.end(); ++p) delete(*p);
|
||||
free(code);
|
||||
lv_free(code);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -229,9 +229,9 @@ struct LottieFont
|
||||
~LottieFont()
|
||||
{
|
||||
for (auto c = chars.begin(); c < chars.end(); ++c) delete(*c);
|
||||
free(style);
|
||||
free(family);
|
||||
free(name);
|
||||
lv_free(style);
|
||||
lv_free(family);
|
||||
lv_free(name);
|
||||
}
|
||||
|
||||
Array<LottieGlyph*> chars;
|
||||
@@ -247,10 +247,10 @@ struct LottieMarker
|
||||
char* name = nullptr;
|
||||
float time = 0.0f;
|
||||
float duration = 0.0f;
|
||||
|
||||
|
||||
~LottieMarker()
|
||||
{
|
||||
free(name);
|
||||
lv_free(name);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -500,7 +500,7 @@ struct LottieTransform : LottieObject
|
||||
};
|
||||
|
||||
|
||||
struct LottieSolid : LottieObject
|
||||
struct LottieSolid : LottieObject
|
||||
{
|
||||
LottieColor color = RGB24{255, 255, 255};
|
||||
LottieOpacity opacity = 255;
|
||||
@@ -836,7 +836,7 @@ struct LottieSlot
|
||||
|
||||
~LottieSlot()
|
||||
{
|
||||
free(sid);
|
||||
lv_free(sid);
|
||||
if (!overridden) return;
|
||||
for (auto pair = pairs.begin(); pair < pairs.end(); ++pair) {
|
||||
delete(pair->prop);
|
||||
|
||||
@@ -373,7 +373,7 @@ template<typename T>
|
||||
bool LottieParser::parseTangent(const char *key, LottieVectorFrame<T>& value)
|
||||
{
|
||||
if (KEY_AS("ti") && getValue(value.inTangent)) ;
|
||||
else if (KEY_AS("to") && getValue(value.outTangent)) ;
|
||||
else if (KEY_AS("to") && getValue(value.outTangent)) ;
|
||||
else return false;
|
||||
|
||||
value.hasTangent = true;
|
||||
@@ -406,7 +406,8 @@ LottieInterpolator* LottieParser::getInterpolator(const char* key, Point& in, Po
|
||||
|
||||
//new interpolator
|
||||
if (!interpolator) {
|
||||
interpolator = static_cast<LottieInterpolator*>(malloc(sizeof(LottieInterpolator)));
|
||||
interpolator = static_cast<LottieInterpolator*>(lv_malloc(sizeof(LottieInterpolator)));
|
||||
LV_ASSERT_MALLOC(interpolator);
|
||||
interpolator->set(key, in, out);
|
||||
comp->interpolators.push(interpolator);
|
||||
}
|
||||
@@ -944,7 +945,8 @@ LottieImage* LottieParser::parseImage(const char* data, const char* subPath, boo
|
||||
//external image resource
|
||||
} else {
|
||||
auto len = strlen(dirName) + strlen(subPath) + strlen(data) + 1;
|
||||
image->path = static_cast<char*>(malloc(len));
|
||||
image->path = static_cast<char*>(lv_malloc(len));
|
||||
LV_ASSERT_MALLOC(image->path);
|
||||
snprintf(image->path, len, "%s%s%s", dirName, subPath, data);
|
||||
}
|
||||
|
||||
@@ -1024,16 +1026,16 @@ void LottieParser::parseAssets()
|
||||
LottieMarker* LottieParser::parseMarker()
|
||||
{
|
||||
enterObject();
|
||||
|
||||
|
||||
auto marker = new LottieMarker;
|
||||
|
||||
|
||||
while (auto key = nextObjectKey()) {
|
||||
if (KEY_AS("cm")) marker->name = getStringCopy();
|
||||
else if (KEY_AS("tm")) marker->time = getFloat();
|
||||
else if (KEY_AS("dr")) marker->duration = getFloat();
|
||||
else skip(key);
|
||||
}
|
||||
|
||||
|
||||
return marker;
|
||||
}
|
||||
|
||||
@@ -1406,8 +1408,8 @@ void LottieParser::postProcess(Array<LottieGlyph*>& glyphs)
|
||||
auto& font = comp->fonts[i];
|
||||
if (!strcmp(font->family, glyph->family) && !strcmp(font->style, glyph->style)) {
|
||||
font->chars.push(glyph);
|
||||
free(glyph->family);
|
||||
free(glyph->style);
|
||||
lv_free(glyph->family);
|
||||
lv_free(glyph->style);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ const char* LookaheadParserHandler::getString()
|
||||
char* LookaheadParserHandler::getStringCopy()
|
||||
{
|
||||
auto str = getString();
|
||||
if (str) return strdup(str);
|
||||
if (str) return lv_strdup(str);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ struct LottieExpression
|
||||
|
||||
~LottieExpression()
|
||||
{
|
||||
free(code);
|
||||
lv_free(code);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -364,17 +364,17 @@ struct LottiePathSet : LottieProperty
|
||||
exp = nullptr;
|
||||
}
|
||||
|
||||
free(value.cmds);
|
||||
free(value.pts);
|
||||
lv_free(value.cmds);
|
||||
lv_free(value.pts);
|
||||
|
||||
if (!frames) return;
|
||||
|
||||
for (auto p = frames->begin(); p < frames->end(); ++p) {
|
||||
free((*p).value.cmds);
|
||||
free((*p).value.pts);
|
||||
lv_free((*p).value.cmds);
|
||||
lv_free((*p).value.pts);
|
||||
}
|
||||
free(frames->data);
|
||||
free(frames);
|
||||
lv_free(frames->data);
|
||||
lv_free(frames);
|
||||
}
|
||||
|
||||
uint32_t nearest(float frameNo) override
|
||||
@@ -395,7 +395,8 @@ struct LottiePathSet : LottieProperty
|
||||
LottieScalarFrame<PathSet>& newFrame()
|
||||
{
|
||||
if (!frames) {
|
||||
frames = static_cast<Array<LottieScalarFrame<PathSet>>*>(calloc(1, sizeof(Array<LottieScalarFrame<PathSet>>)));
|
||||
frames = static_cast<Array<LottieScalarFrame<PathSet>>*>(lv_zalloc(sizeof(Array<LottieScalarFrame<PathSet>>)));
|
||||
LV_ASSERT_MALLOC(frames);
|
||||
}
|
||||
if (frames->count + 1 >= frames->reserved) {
|
||||
auto old = frames->reserved;
|
||||
@@ -465,7 +466,8 @@ struct LottiePathSet : LottieProperty
|
||||
return true;
|
||||
}
|
||||
|
||||
auto interpPts = (Point*)malloc(frame->value.ptsCnt * sizeof(Point));
|
||||
auto interpPts = (Point*)lv_malloc(frame->value.ptsCnt * sizeof(Point));
|
||||
LV_ASSERT_MALLOC(interpPts);
|
||||
auto p = interpPts;
|
||||
for (auto i = 0; i < frame->value.ptsCnt; ++i, ++s, ++e, ++p) {
|
||||
*p = lerp(*s, *e, t);
|
||||
@@ -481,7 +483,7 @@ struct LottiePathSet : LottieProperty
|
||||
} else roundness->modifyPath(frame->value.cmds, frame->value.cmdsCnt, interpPts, frame->value.ptsCnt, cmds, pts, nullptr);
|
||||
} else if (offsetPath) offsetPath->modifyPath(frame->value.cmds, frame->value.cmdsCnt, interpPts, frame->value.ptsCnt, cmds, pts);
|
||||
|
||||
free(interpPts);
|
||||
lv_free(interpPts);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -520,17 +522,17 @@ struct LottieColorStop : LottieProperty
|
||||
}
|
||||
|
||||
if (value.data) {
|
||||
free(value.data);
|
||||
lv_free(value.data);
|
||||
value.data = nullptr;
|
||||
}
|
||||
|
||||
if (!frames) return;
|
||||
|
||||
for (auto p = frames->begin(); p < frames->end(); ++p) {
|
||||
free((*p).value.data);
|
||||
lv_free((*p).value.data);
|
||||
}
|
||||
free(frames->data);
|
||||
free(frames);
|
||||
lv_free(frames->data);
|
||||
lv_free(frames);
|
||||
frames = nullptr;
|
||||
}
|
||||
|
||||
@@ -552,7 +554,8 @@ struct LottieColorStop : LottieProperty
|
||||
LottieScalarFrame<ColorStop>& newFrame()
|
||||
{
|
||||
if (!frames) {
|
||||
frames = static_cast<Array<LottieScalarFrame<ColorStop>>*>(calloc(1, sizeof(Array<LottieScalarFrame<ColorStop>>)));
|
||||
frames = static_cast<Array<LottieScalarFrame<ColorStop>>*>(lv_zalloc(sizeof(Array<LottieScalarFrame<ColorStop>>)));
|
||||
LV_ASSERT_MALLOC(frames);
|
||||
}
|
||||
if (frames->count + 1 >= frames->reserved) {
|
||||
auto old = frames->reserved;
|
||||
@@ -753,19 +756,19 @@ struct LottieTextDoc : LottieProperty
|
||||
}
|
||||
|
||||
if (value.text) {
|
||||
free(value.text);
|
||||
lv_free(value.text);
|
||||
value.text = nullptr;
|
||||
}
|
||||
if (value.name) {
|
||||
free(value.name);
|
||||
lv_free(value.name);
|
||||
value.name = nullptr;
|
||||
}
|
||||
|
||||
if (!frames) return;
|
||||
|
||||
for (auto p = frames->begin(); p < frames->end(); ++p) {
|
||||
free((*p).value.text);
|
||||
free((*p).value.name);
|
||||
lv_free((*p).value.text);
|
||||
lv_free((*p).value.name);
|
||||
}
|
||||
delete(frames);
|
||||
frames = nullptr;
|
||||
|
||||
@@ -366,7 +366,7 @@ void Paint::Impl::reset()
|
||||
|
||||
if (compData) {
|
||||
if (P(compData->target)->unref() == 0) delete(compData->target);
|
||||
free(compData);
|
||||
lv_free(compData);
|
||||
compData = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace tvg
|
||||
{
|
||||
if (compData) {
|
||||
if (P(compData->target)->unref() == 0) delete(compData->target);
|
||||
free(compData);
|
||||
lv_free(compData);
|
||||
}
|
||||
if (clipper && P(clipper)->unref() == 0) delete(clipper);
|
||||
if (renderer && (renderer->unref() == 0)) delete(renderer);
|
||||
@@ -151,13 +151,14 @@ namespace tvg
|
||||
}
|
||||
//Reset scenario
|
||||
if (!target && method == CompositeMethod::None) {
|
||||
free(compData);
|
||||
lv_free(compData);
|
||||
compData = nullptr;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (!target && method == CompositeMethod::None) return true;
|
||||
compData = static_cast<Composite*>(calloc(1, sizeof(Composite)));
|
||||
compData = static_cast<Composite*>(lv_zalloc(sizeof(Composite)));
|
||||
LV_ASSERT_MALLOC(compData);
|
||||
}
|
||||
P(target)->ref();
|
||||
compData->target = target;
|
||||
|
||||
@@ -44,7 +44,7 @@ RawLoader::RawLoader() : ImageLoader(FileType::Raw)
|
||||
|
||||
RawLoader::~RawLoader()
|
||||
{
|
||||
if (copy) free(surface.buf32);
|
||||
if (copy) lv_free(surface.buf32);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,8 @@ bool RawLoader::open(const uint32_t* data, uint32_t w, uint32_t h, bool copy)
|
||||
this->copy = copy;
|
||||
|
||||
if (copy) {
|
||||
surface.buf32 = (uint32_t*)malloc(sizeof(uint32_t) * w * h);
|
||||
surface.buf32 = (uint32_t*)lv_malloc(sizeof(uint32_t) * w * h);
|
||||
LV_ASSERT_MALLOC(surface.buf32);
|
||||
if (!surface.buf32) return false;
|
||||
memcpy((void*)surface.buf32, data, sizeof(uint32_t) * w * h);
|
||||
}
|
||||
|
||||
@@ -132,9 +132,10 @@ struct RenderStroke
|
||||
if (rhs.fill) fill = rhs.fill->duplicate();
|
||||
else fill = nullptr;
|
||||
|
||||
free(dashPattern);
|
||||
lv_free(dashPattern);
|
||||
if (rhs.dashCnt > 0) {
|
||||
dashPattern = static_cast<float*>(malloc(sizeof(float) * rhs.dashCnt));
|
||||
dashPattern = static_cast<float*>(lv_malloc(sizeof(float) * rhs.dashCnt));
|
||||
LV_ASSERT_MALLOC(dashPattern);
|
||||
memcpy(dashPattern, rhs.dashPattern, sizeof(float) * rhs.dashCnt);
|
||||
} else {
|
||||
dashPattern = nullptr;
|
||||
@@ -175,7 +176,7 @@ struct RenderStroke
|
||||
|
||||
~RenderStroke()
|
||||
{
|
||||
free(dashPattern);
|
||||
lv_free(dashPattern);
|
||||
delete(fill);
|
||||
}
|
||||
};
|
||||
@@ -275,7 +276,7 @@ struct RenderEffect
|
||||
|
||||
virtual ~RenderEffect()
|
||||
{
|
||||
free(rd);
|
||||
lv_free(rd);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ struct Shape::Impl
|
||||
|
||||
if ((needComp = needComposition(opacity))) {
|
||||
/* Overriding opacity value. If this scene is half-translucent,
|
||||
It must do intermediate composition with that opacity value. */
|
||||
It must do intermediate composition with that opacity value. */
|
||||
this->opacity = opacity;
|
||||
opacity = 255;
|
||||
}
|
||||
@@ -310,16 +310,17 @@ struct Shape::Impl
|
||||
|
||||
//Reset dash
|
||||
if (!pattern && cnt == 0) {
|
||||
free(rs.stroke->dashPattern);
|
||||
lv_free(rs.stroke->dashPattern);
|
||||
rs.stroke->dashPattern = nullptr;
|
||||
} else {
|
||||
if (!rs.stroke) rs.stroke = new RenderStroke();
|
||||
if (rs.stroke->dashCnt != cnt) {
|
||||
free(rs.stroke->dashPattern);
|
||||
lv_free(rs.stroke->dashPattern);
|
||||
rs.stroke->dashPattern = nullptr;
|
||||
}
|
||||
if (!rs.stroke->dashPattern) {
|
||||
rs.stroke->dashPattern = static_cast<float*>(malloc(sizeof(float) * cnt));
|
||||
rs.stroke->dashPattern = static_cast<float*>(lv_malloc(sizeof(float) * cnt));
|
||||
LV_ASSERT_MALLOC(rs.stroke->dashPattern);
|
||||
if (!rs.stroke->dashPattern) return Result::FailedAllocation;
|
||||
}
|
||||
for (uint32_t i = 0; i < cnt; ++i) {
|
||||
|
||||
@@ -215,7 +215,8 @@ char* strDuplicate(const char *str, size_t n)
|
||||
auto len = strlen(str);
|
||||
if (len < n) n = len;
|
||||
|
||||
auto ret = (char *) malloc(n + 1);
|
||||
auto ret = (char *) lv_malloc(n + 1);
|
||||
LV_ASSERT_MALLOC(ret);
|
||||
if (!ret) return nullptr;
|
||||
ret[n] = '\0';
|
||||
|
||||
@@ -226,7 +227,8 @@ char* strAppend(char* lhs, const char* rhs, size_t n)
|
||||
{
|
||||
if (!rhs) return lhs;
|
||||
if (!lhs) return strDuplicate(rhs, n);
|
||||
lhs = (char*)realloc(lhs, strlen(lhs) + n + 1);
|
||||
lhs = (char*)lv_realloc(lhs, strlen(lhs) + n + 1);
|
||||
LV_ASSERT_MALLOC(lhs);
|
||||
return strncat(lhs, rhs, n);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,8 +75,8 @@ static void _copyStyle(SvgStyleProperty* to, const SvgStyleProperty* from)
|
||||
to->fill.paint.none = from->fill.paint.none;
|
||||
to->fill.paint.curColor = from->fill.paint.curColor;
|
||||
if (from->fill.paint.url) {
|
||||
if (to->fill.paint.url) free(to->fill.paint.url);
|
||||
to->fill.paint.url = strdup(from->fill.paint.url);
|
||||
if (to->fill.paint.url) lv_free(to->fill.paint.url);
|
||||
to->fill.paint.url = lv_strdup(from->fill.paint.url);
|
||||
}
|
||||
to->fill.flags = (to->fill.flags | SvgFillFlags::Paint);
|
||||
to->flags = (to->flags | SvgStyleFlags::Fill);
|
||||
@@ -109,8 +109,8 @@ static void _copyStyle(SvgStyleProperty* to, const SvgStyleProperty* from)
|
||||
to->stroke.paint.none = from->stroke.paint.none;
|
||||
to->stroke.paint.curColor = from->stroke.paint.curColor;
|
||||
if (from->stroke.paint.url) {
|
||||
if (to->stroke.paint.url) free(to->stroke.paint.url);
|
||||
to->stroke.paint.url = strdup(from->stroke.paint.url);
|
||||
if (to->stroke.paint.url) lv_free(to->stroke.paint.url);
|
||||
to->stroke.paint.url = lv_strdup(from->stroke.paint.url);
|
||||
}
|
||||
to->stroke.flags = (to->stroke.flags | SvgStrokeFlags::Paint);
|
||||
to->flags = (to->flags | SvgStyleFlags::Stroke);
|
||||
@@ -190,7 +190,8 @@ void cssCopyStyleAttr(SvgNode* to, const SvgNode* from)
|
||||
{
|
||||
//Copy matrix attribute
|
||||
if (from->transform && !(to->style->flags & SvgStyleFlags::Transform)) {
|
||||
to->transform = (Matrix*)malloc(sizeof(Matrix));
|
||||
to->transform = (Matrix*)lv_malloc(sizeof(Matrix));
|
||||
LV_ASSERT_MALLOC(to->transform);
|
||||
if (to->transform) {
|
||||
*to->transform = *from->transform;
|
||||
to->style->flags = (to->style->flags | SvgStyleFlags::Transform);
|
||||
@@ -200,12 +201,12 @@ void cssCopyStyleAttr(SvgNode* to, const SvgNode* from)
|
||||
_copyStyle(to->style, from->style);
|
||||
|
||||
if (from->style->clipPath.url) {
|
||||
if (to->style->clipPath.url) free(to->style->clipPath.url);
|
||||
to->style->clipPath.url = strdup(from->style->clipPath.url);
|
||||
if (to->style->clipPath.url) lv_free(to->style->clipPath.url);
|
||||
to->style->clipPath.url = lv_strdup(from->style->clipPath.url);
|
||||
}
|
||||
if (from->style->mask.url) {
|
||||
if (to->style->mask.url) free(to->style->mask.url);
|
||||
to->style->mask.url = strdup(from->style->mask.url);
|
||||
if (to->style->mask.url) lv_free(to->style->mask.url);
|
||||
to->style->mask.url = lv_strdup(from->style->mask.url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ static char* _copyId(const char* str)
|
||||
if (!str) return nullptr;
|
||||
if (strlen(str) == 0) return nullptr;
|
||||
|
||||
return strdup(str);
|
||||
return lv_strdup(str);
|
||||
}
|
||||
|
||||
|
||||
@@ -714,7 +714,7 @@ static bool _toColor(const char* str, uint8_t* r, uint8_t* g, uint8_t* b, char**
|
||||
}
|
||||
return true;
|
||||
} else if (ref && len >= 3 && !strncmp(str, "url", 3)) {
|
||||
if (*ref) free(*ref);
|
||||
if (*ref) lv_free(*ref);
|
||||
*ref = _idFromUrl((const char*)(str + 3));
|
||||
return true;
|
||||
} else if (len >= 10 && (str[0] == 'h' || str[0] == 'H') && (str[1] == 's' || str[1] == 'S') && (str[2] == 'l' || str[2] == 'L') && str[3] == '(' && str[len - 1] == ')') {
|
||||
@@ -814,7 +814,9 @@ static Matrix* _parseTransformationMatrix(const char* value)
|
||||
{
|
||||
const int POINT_CNT = 8;
|
||||
|
||||
auto matrix = (Matrix*)malloc(sizeof(Matrix));
|
||||
auto matrix = (Matrix*)lv_malloc(sizeof(Matrix));
|
||||
LV_ASSERT_MALLOC(matrix);
|
||||
|
||||
if (!matrix) return nullptr;
|
||||
*matrix = {1, 0, 0, 0, 1, 0, 0, 0, 1};
|
||||
|
||||
@@ -898,7 +900,7 @@ static Matrix* _parseTransformationMatrix(const char* value)
|
||||
}
|
||||
return matrix;
|
||||
error:
|
||||
if (matrix) free(matrix);
|
||||
if (matrix) lv_free(matrix);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1136,7 +1138,7 @@ static void _handleClipPathAttr(TVG_UNUSED SvgLoaderData* loader, SvgNode* node,
|
||||
SvgStyleProperty* style = node->style;
|
||||
int len = strlen(value);
|
||||
if (len >= 3 && !strncmp(value, "url", 3)) {
|
||||
if (style->clipPath.url) free(style->clipPath.url);
|
||||
if (style->clipPath.url) lv_free(style->clipPath.url);
|
||||
style->clipPath.url = _idFromUrl((const char*)(value + 3));
|
||||
}
|
||||
}
|
||||
@@ -1147,7 +1149,7 @@ static void _handleMaskAttr(TVG_UNUSED SvgLoaderData* loader, SvgNode* node, con
|
||||
SvgStyleProperty* style = node->style;
|
||||
int len = strlen(value);
|
||||
if (len >= 3 && !strncmp(value, "url", 3)) {
|
||||
if (style->mask.url) free(style->mask.url);
|
||||
if (style->mask.url) lv_free(style->mask.url);
|
||||
style->mask.url = _idFromUrl((const char*)(value + 3));
|
||||
}
|
||||
}
|
||||
@@ -1182,7 +1184,7 @@ static void _handleCssClassAttr(SvgLoaderData* loader, SvgNode* node, const char
|
||||
{
|
||||
auto cssClass = &node->style->cssClass;
|
||||
|
||||
if (*cssClass && value) free(*cssClass);
|
||||
if (*cssClass && value) lv_free(*cssClass);
|
||||
*cssClass = _copyId(value);
|
||||
|
||||
bool cssClassFound = false;
|
||||
@@ -1268,7 +1270,7 @@ static bool _parseStyleAttr(void* data, const char* key, const char* value, bool
|
||||
}
|
||||
if (importance) {
|
||||
node->style->flagsImportance = (node->style->flags | styleTags[i].flag);
|
||||
free(const_cast<char*>(value));
|
||||
lv_free(const_cast<char*>(value));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1297,7 +1299,7 @@ static bool _attrParseGNode(void* data, const char* key, const char* value)
|
||||
} else if (!strcmp(key, "transform")) {
|
||||
node->transform = _parseTransformationMatrix(value);
|
||||
} else if (!strcmp(key, "id")) {
|
||||
if (node->id && value) free(node->id);
|
||||
if (node->id && value) lv_free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "class")) {
|
||||
_handleCssClassAttr(loader, node, value);
|
||||
@@ -1326,7 +1328,7 @@ static bool _attrParseClipPathNode(void* data, const char* key, const char* valu
|
||||
} else if (!strcmp(key, "transform")) {
|
||||
node->transform = _parseTransformationMatrix(value);
|
||||
} else if (!strcmp(key, "id")) {
|
||||
if (node->id && value) free(node->id);
|
||||
if (node->id && value) lv_free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "class")) {
|
||||
_handleCssClassAttr(loader, node, value);
|
||||
@@ -1350,7 +1352,7 @@ static bool _attrParseMaskNode(void* data, const char* key, const char* value)
|
||||
} else if (!strcmp(key, "transform")) {
|
||||
node->transform = _parseTransformationMatrix(value);
|
||||
} else if (!strcmp(key, "id")) {
|
||||
if (node->id && value) free(node->id);
|
||||
if (node->id && value) lv_free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "class")) {
|
||||
_handleCssClassAttr(loader, node, value);
|
||||
@@ -1371,7 +1373,7 @@ static bool _attrParseCssStyleNode(void* data, const char* key, const char* valu
|
||||
SvgNode* node = loader->svgParse->node;
|
||||
|
||||
if (!strcmp(key, "id")) {
|
||||
if (node->id && value) free(node->id);
|
||||
if (node->id && value) lv_free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else {
|
||||
return _parseStyleAttr(loader, key, value, false);
|
||||
@@ -1410,15 +1412,17 @@ static bool _attrParseSymbolNode(void* data, const char* key, const char* value)
|
||||
|
||||
static SvgNode* _createNode(SvgNode* parent, SvgNodeType type)
|
||||
{
|
||||
SvgNode* node = (SvgNode*)calloc(1, sizeof(SvgNode));
|
||||
SvgNode* node = (SvgNode*)lv_zalloc(sizeof(SvgNode));
|
||||
LV_ASSERT_MALLOC(node);
|
||||
|
||||
if (!node) return nullptr;
|
||||
|
||||
//Default fill property
|
||||
node->style = (SvgStyleProperty*)calloc(1, sizeof(SvgStyleProperty));
|
||||
node->style = (SvgStyleProperty*)lv_zalloc(sizeof(SvgStyleProperty));
|
||||
LV_ASSERT_MALLOC(node->style);
|
||||
|
||||
if (!node->style) {
|
||||
free(node);
|
||||
lv_free(node);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1576,7 +1580,7 @@ static bool _attrParsePathNode(void* data, const char* key, const char* value)
|
||||
SvgPathNode* path = &(node->node.path);
|
||||
|
||||
if (!strcmp(key, "d")) {
|
||||
if (path->path) free(path->path);
|
||||
if (path->path) lv_free(path->path);
|
||||
//Temporary: need to copy
|
||||
path->path = _copyId(value);
|
||||
} else if (!strcmp(key, "style")) {
|
||||
@@ -1586,7 +1590,7 @@ static bool _attrParsePathNode(void* data, const char* key, const char* value)
|
||||
} else if (!strcmp(key, "mask")) {
|
||||
_handleMaskAttr(loader, node, value);
|
||||
} else if (!strcmp(key, "id")) {
|
||||
if (node->id && value) free(node->id);
|
||||
if (node->id && value) lv_free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "class")) {
|
||||
_handleCssClassAttr(loader, node, value);
|
||||
@@ -1648,7 +1652,7 @@ static bool _attrParseCircleNode(void* data, const char* key, const char* value)
|
||||
} else if (!strcmp(key, "mask")) {
|
||||
_handleMaskAttr(loader, node, value);
|
||||
} else if (!strcmp(key, "id")) {
|
||||
if (node->id && value) free(node->id);
|
||||
if (node->id && value) lv_free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "class")) {
|
||||
_handleCssClassAttr(loader, node, value);
|
||||
@@ -1704,7 +1708,7 @@ static bool _attrParseEllipseNode(void* data, const char* key, const char* value
|
||||
}
|
||||
|
||||
if (!strcmp(key, "id")) {
|
||||
if (node->id && value) free(node->id);
|
||||
if (node->id && value) lv_free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "class")) {
|
||||
_handleCssClassAttr(loader, node, value);
|
||||
@@ -1764,7 +1768,7 @@ static bool _attrParsePolygonNode(void* data, const char* key, const char* value
|
||||
} else if (!strcmp(key, "mask")) {
|
||||
_handleMaskAttr(loader, node, value);
|
||||
} else if (!strcmp(key, "id")) {
|
||||
if (node->id && value) free(node->id);
|
||||
if (node->id && value) lv_free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "class")) {
|
||||
_handleCssClassAttr(loader, node, value);
|
||||
@@ -1840,7 +1844,7 @@ static bool _attrParseRectNode(void* data, const char* key, const char* value)
|
||||
}
|
||||
|
||||
if (!strcmp(key, "id")) {
|
||||
if (node->id && value) free(node->id);
|
||||
if (node->id && value) lv_free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "class")) {
|
||||
_handleCssClassAttr(loader, node, value);
|
||||
@@ -1905,7 +1909,7 @@ static bool _attrParseLineNode(void* data, const char* key, const char* value)
|
||||
}
|
||||
|
||||
if (!strcmp(key, "id")) {
|
||||
if (node->id && value) free(node->id);
|
||||
if (node->id && value) lv_free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "class")) {
|
||||
_handleCssClassAttr(loader, node, value);
|
||||
@@ -1937,7 +1941,7 @@ static char* _idFromHref(const char* href)
|
||||
{
|
||||
href = _skipSpace(href, nullptr);
|
||||
if ((*href) == '#') href++;
|
||||
return strdup(href);
|
||||
return lv_strdup(href);
|
||||
}
|
||||
|
||||
|
||||
@@ -1975,10 +1979,10 @@ static bool _attrParseImageNode(void* data, const char* key, const char* value)
|
||||
}
|
||||
|
||||
if (!strcmp(key, "href") || !strcmp(key, "xlink:href")) {
|
||||
if (image->href && value) free(image->href);
|
||||
if (image->href && value) lv_free(image->href);
|
||||
image->href = _idFromHref(value);
|
||||
} else if (!strcmp(key, "id")) {
|
||||
if (node->id && value) free(node->id);
|
||||
if (node->id && value) lv_free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "class")) {
|
||||
_handleCssClassAttr(loader, node, value);
|
||||
@@ -2100,7 +2104,7 @@ static bool _attrParseUseNode(void* data, const char* key, const char* value)
|
||||
} else {
|
||||
TVGLOG("SVG", "%s is ancestor element. This reference is invalid.", id);
|
||||
}
|
||||
free(id);
|
||||
lv_free(id);
|
||||
} else {
|
||||
//some svg export software include <defs> element at the end of the file
|
||||
//if so the 'from' element won't be found now and we have to repeat finding
|
||||
@@ -2159,8 +2163,8 @@ static bool _attrParseTextNode(void* data, const char* key, const char* value)
|
||||
}
|
||||
|
||||
if (!strcmp(key, "font-family")) {
|
||||
if (text->fontFamily && value) free(text->fontFamily);
|
||||
text->fontFamily = strdup(value);
|
||||
if (text->fontFamily && value) lv_free(text->fontFamily);
|
||||
text->fontFamily = lv_strdup(value);
|
||||
} else if (!strcmp(key, "style")) {
|
||||
return simpleXmlParseW3CAttribute(value, strlen(value), _parseStyleAttr, loader);
|
||||
} else if (!strcmp(key, "clip-path")) {
|
||||
@@ -2168,7 +2172,7 @@ static bool _attrParseTextNode(void* data, const char* key, const char* value)
|
||||
} else if (!strcmp(key, "mask")) {
|
||||
_handleMaskAttr(loader, node, value);
|
||||
} else if (!strcmp(key, "id")) {
|
||||
if (node->id && value) free(node->id);
|
||||
if (node->id && value) lv_free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "class")) {
|
||||
_handleCssClassAttr(loader, node, value);
|
||||
@@ -2495,13 +2499,13 @@ static bool _attrParseRadialGradientNode(void* data, const char* key, const char
|
||||
}
|
||||
|
||||
if (!strcmp(key, "id")) {
|
||||
if (grad->id && value) free(grad->id);
|
||||
if (grad->id && value) lv_free(grad->id);
|
||||
grad->id = _copyId(value);
|
||||
} else if (!strcmp(key, "spreadMethod")) {
|
||||
grad->spread = _parseSpreadValue(value);
|
||||
grad->flags = (grad->flags | SvgGradientFlags::SpreadMethod);
|
||||
} else if (!strcmp(key, "href") || !strcmp(key, "xlink:href")) {
|
||||
if (grad->ref && value) free(grad->ref);
|
||||
if (grad->ref && value) lv_free(grad->ref);
|
||||
grad->ref = _idFromHref(value);
|
||||
} else if (!strcmp(key, "gradientUnits")) {
|
||||
if (!strcmp(value, "userSpaceOnUse")) grad->userSpace = true;
|
||||
@@ -2518,16 +2522,18 @@ static bool _attrParseRadialGradientNode(void* data, const char* key, const char
|
||||
|
||||
static SvgStyleGradient* _createRadialGradient(SvgLoaderData* loader, const char* buf, unsigned bufLength)
|
||||
{
|
||||
auto grad = (SvgStyleGradient*)(calloc(1, sizeof(SvgStyleGradient)));
|
||||
auto grad = (SvgStyleGradient*)(lv_zalloc(sizeof(SvgStyleGradient)));
|
||||
LV_ASSERT_MALLOC(grad);
|
||||
loader->svgParse->styleGrad = grad;
|
||||
|
||||
grad->flags = SvgGradientFlags::None;
|
||||
grad->type = SvgGradientType::Radial;
|
||||
grad->userSpace = false;
|
||||
grad->radial = (SvgRadialGradient*)calloc(1, sizeof(SvgRadialGradient));
|
||||
grad->radial = (SvgRadialGradient*)lv_zalloc(sizeof(SvgRadialGradient));
|
||||
LV_ASSERT_MALLOC(grad->radial);
|
||||
if (!grad->radial) {
|
||||
grad->clear();
|
||||
free(grad);
|
||||
lv_free(grad);
|
||||
return nullptr;
|
||||
}
|
||||
/**
|
||||
@@ -2763,13 +2769,13 @@ static bool _attrParseLinearGradientNode(void* data, const char* key, const char
|
||||
}
|
||||
|
||||
if (!strcmp(key, "id")) {
|
||||
if (grad->id && value) free(grad->id);
|
||||
if (grad->id && value) lv_free(grad->id);
|
||||
grad->id = _copyId(value);
|
||||
} else if (!strcmp(key, "spreadMethod")) {
|
||||
grad->spread = _parseSpreadValue(value);
|
||||
grad->flags = (grad->flags | SvgGradientFlags::SpreadMethod);
|
||||
} else if (!strcmp(key, "href") || !strcmp(key, "xlink:href")) {
|
||||
if (grad->ref && value) free(grad->ref);
|
||||
if (grad->ref && value) lv_free(grad->ref);
|
||||
grad->ref = _idFromHref(value);
|
||||
} else if (!strcmp(key, "gradientUnits")) {
|
||||
if (!strcmp(value, "userSpaceOnUse")) grad->userSpace = true;
|
||||
@@ -2786,16 +2792,18 @@ static bool _attrParseLinearGradientNode(void* data, const char* key, const char
|
||||
|
||||
static SvgStyleGradient* _createLinearGradient(SvgLoaderData* loader, const char* buf, unsigned bufLength)
|
||||
{
|
||||
auto grad = (SvgStyleGradient*)(calloc(1, sizeof(SvgStyleGradient)));
|
||||
auto grad = (SvgStyleGradient*)(lv_zalloc(sizeof(SvgStyleGradient)));
|
||||
LV_ASSERT_MALLOC(grad);
|
||||
loader->svgParse->styleGrad = grad;
|
||||
|
||||
grad->flags = SvgGradientFlags::None;
|
||||
grad->type = SvgGradientType::Linear;
|
||||
grad->userSpace = false;
|
||||
grad->linear = (SvgLinearGradient*)calloc(1, sizeof(SvgLinearGradient));
|
||||
grad->linear = (SvgLinearGradient*)lv_zalloc(sizeof(SvgLinearGradient));
|
||||
LV_ASSERT_MALLOC(grad->linear);
|
||||
if (!grad->linear) {
|
||||
grad->clear();
|
||||
free(grad);
|
||||
lv_free(grad);
|
||||
return nullptr;
|
||||
}
|
||||
/**
|
||||
@@ -2872,7 +2880,8 @@ static void _inheritGradient(SvgLoaderData* loader, SvgStyleGradient* to, SvgSty
|
||||
}
|
||||
|
||||
if (!to->transform && from->transform) {
|
||||
to->transform = (Matrix*)malloc(sizeof(Matrix));
|
||||
to->transform = (Matrix*)lv_malloc(sizeof(Matrix));
|
||||
LV_ASSERT_MALLOC(to->transform);
|
||||
if (to->transform) memcpy(to->transform, from->transform, sizeof(Matrix));
|
||||
}
|
||||
|
||||
@@ -2926,7 +2935,8 @@ static SvgStyleGradient* _cloneGradient(SvgStyleGradient* from)
|
||||
{
|
||||
if (!from) return nullptr;
|
||||
|
||||
auto grad = (SvgStyleGradient*)(calloc(1, sizeof(SvgStyleGradient)));
|
||||
auto grad = (SvgStyleGradient*)(lv_zalloc(sizeof(SvgStyleGradient)));
|
||||
LV_ASSERT_MALLOC(grad);
|
||||
if (!grad) return nullptr;
|
||||
|
||||
grad->type = from->type;
|
||||
@@ -2937,16 +2947,19 @@ static SvgStyleGradient* _cloneGradient(SvgStyleGradient* from)
|
||||
grad->flags = from->flags;
|
||||
|
||||
if (from->transform) {
|
||||
grad->transform = (Matrix*)calloc(1, sizeof(Matrix));
|
||||
grad->transform = (Matrix*)lv_zalloc(sizeof(Matrix));
|
||||
LV_ASSERT_MALLOC(grad->transform);
|
||||
if (grad->transform) memcpy(grad->transform, from->transform, sizeof(Matrix));
|
||||
}
|
||||
|
||||
if (grad->type == SvgGradientType::Linear) {
|
||||
grad->linear = (SvgLinearGradient*)calloc(1, sizeof(SvgLinearGradient));
|
||||
grad->linear = (SvgLinearGradient*)lv_zalloc(sizeof(SvgLinearGradient));
|
||||
LV_ASSERT_MALLOC(grad->linear);
|
||||
if (!grad->linear) goto error_grad_alloc;
|
||||
memcpy(grad->linear, from->linear, sizeof(SvgLinearGradient));
|
||||
} else if (grad->type == SvgGradientType::Radial) {
|
||||
grad->radial = (SvgRadialGradient*)calloc(1, sizeof(SvgRadialGradient));
|
||||
grad->radial = (SvgRadialGradient*)lv_zalloc(sizeof(SvgRadialGradient));
|
||||
LV_ASSERT_MALLOC(grad->radial);
|
||||
if (!grad->radial) goto error_grad_alloc;
|
||||
memcpy(grad->radial, from->radial, sizeof(SvgRadialGradient));
|
||||
}
|
||||
@@ -2958,7 +2971,7 @@ static SvgStyleGradient* _cloneGradient(SvgStyleGradient* from)
|
||||
error_grad_alloc:
|
||||
if (grad) {
|
||||
grad->clear();
|
||||
free(grad);
|
||||
lv_free(grad);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -2981,7 +2994,7 @@ static void _styleInherit(SvgStyleProperty* child, const SvgStyleProperty* paren
|
||||
child->fill.paint.none = parent->fill.paint.none;
|
||||
child->fill.paint.curColor = parent->fill.paint.curColor;
|
||||
if (parent->fill.paint.url) {
|
||||
if (child->fill.paint.url) free(child->fill.paint.url);
|
||||
if (child->fill.paint.url) lv_free(child->fill.paint.url);
|
||||
child->fill.paint.url = _copyId(parent->fill.paint.url);
|
||||
}
|
||||
}
|
||||
@@ -2997,7 +3010,7 @@ static void _styleInherit(SvgStyleProperty* child, const SvgStyleProperty* paren
|
||||
child->stroke.paint.none = parent->stroke.paint.none;
|
||||
child->stroke.paint.curColor = parent->stroke.paint.curColor;
|
||||
if (parent->stroke.paint.url) {
|
||||
if (child->stroke.paint.url) free(child->stroke.paint.url);
|
||||
if (child->stroke.paint.url) lv_free(child->stroke.paint.url);
|
||||
child->stroke.paint.url = _copyId(parent->stroke.paint.url);
|
||||
}
|
||||
}
|
||||
@@ -3055,7 +3068,7 @@ static void _styleCopy(SvgStyleProperty* to, const SvgStyleProperty* from)
|
||||
to->fill.paint.none = from->fill.paint.none;
|
||||
to->fill.paint.curColor = from->fill.paint.curColor;
|
||||
if (from->fill.paint.url) {
|
||||
if (to->fill.paint.url) free(to->fill.paint.url);
|
||||
if (to->fill.paint.url) lv_free(to->fill.paint.url);
|
||||
to->fill.paint.url = _copyId(from->fill.paint.url);
|
||||
}
|
||||
}
|
||||
@@ -3072,7 +3085,7 @@ static void _styleCopy(SvgStyleProperty* to, const SvgStyleProperty* from)
|
||||
to->stroke.paint.none = from->stroke.paint.none;
|
||||
to->stroke.paint.curColor = from->stroke.paint.curColor;
|
||||
if (from->stroke.paint.url) {
|
||||
if (to->stroke.paint.url) free(to->stroke.paint.url);
|
||||
if (to->stroke.paint.url) lv_free(to->stroke.paint.url);
|
||||
to->stroke.paint.url = _copyId(from->stroke.paint.url);
|
||||
}
|
||||
}
|
||||
@@ -3110,19 +3123,20 @@ static void _copyAttr(SvgNode* to, const SvgNode* from)
|
||||
{
|
||||
//Copy matrix attribute
|
||||
if (from->transform) {
|
||||
to->transform = (Matrix*)malloc(sizeof(Matrix));
|
||||
to->transform = (Matrix*)lv_malloc(sizeof(Matrix));
|
||||
LV_ASSERT_MALLOC(to->transform);
|
||||
if (to->transform) *to->transform = *from->transform;
|
||||
}
|
||||
//Copy style attribute
|
||||
_styleCopy(to->style, from->style);
|
||||
to->style->flags = (to->style->flags | from->style->flags);
|
||||
if (from->style->clipPath.url) {
|
||||
if (to->style->clipPath.url) free(to->style->clipPath.url);
|
||||
to->style->clipPath.url = strdup(from->style->clipPath.url);
|
||||
if (to->style->clipPath.url) lv_free(to->style->clipPath.url);
|
||||
to->style->clipPath.url = lv_strdup(from->style->clipPath.url);
|
||||
}
|
||||
if (from->style->mask.url) {
|
||||
if (to->style->mask.url) free(to->style->mask.url);
|
||||
to->style->mask.url = strdup(from->style->mask.url);
|
||||
if (to->style->mask.url) lv_free(to->style->mask.url);
|
||||
to->style->mask.url = lv_strdup(from->style->mask.url);
|
||||
}
|
||||
|
||||
//Copy node attribute
|
||||
@@ -3160,8 +3174,8 @@ static void _copyAttr(SvgNode* to, const SvgNode* from)
|
||||
}
|
||||
case SvgNodeType::Path: {
|
||||
if (from->node.path.path) {
|
||||
if (to->node.path.path) free(to->node.path.path);
|
||||
to->node.path.path = strdup(from->node.path.path);
|
||||
if (to->node.path.path) lv_free(to->node.path.path);
|
||||
to->node.path.path = lv_strdup(from->node.path.path);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -3183,8 +3197,8 @@ static void _copyAttr(SvgNode* to, const SvgNode* from)
|
||||
to->node.image.w = from->node.image.w;
|
||||
to->node.image.h = from->node.image.h;
|
||||
if (from->node.image.href) {
|
||||
if (to->node.image.href) free(to->node.image.href);
|
||||
to->node.image.href = strdup(from->node.image.href);
|
||||
if (to->node.image.href) lv_free(to->node.image.href);
|
||||
to->node.image.href = lv_strdup(from->node.image.href);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -3203,12 +3217,12 @@ static void _copyAttr(SvgNode* to, const SvgNode* from)
|
||||
to->node.text.y = from->node.text.y;
|
||||
to->node.text.fontSize = from->node.text.fontSize;
|
||||
if (from->node.text.text) {
|
||||
if (to->node.text.text) free(to->node.text.text);
|
||||
to->node.text.text = strdup(from->node.text.text);
|
||||
if (to->node.text.text) lv_free(to->node.text.text);
|
||||
to->node.text.text = lv_strdup(from->node.text.text);
|
||||
}
|
||||
if (from->node.text.fontFamily) {
|
||||
if (to->node.text.fontFamily) free(to->node.text.fontFamily);
|
||||
to->node.text.fontFamily = strdup(from->node.text.fontFamily);
|
||||
if (to->node.text.fontFamily) lv_free(to->node.text.fontFamily);
|
||||
to->node.text.fontFamily = lv_strdup(from->node.text.fontFamily);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -3259,7 +3273,7 @@ static void _clonePostponedNodes(Array<SvgNodeIdPair>* cloneNodes, SvgNode* doc)
|
||||
} else {
|
||||
TVGLOG("SVG", "%s is ancestor element. This reference is invalid.", nodeIdPair.id);
|
||||
}
|
||||
free(nodeIdPair.id);
|
||||
lv_free(nodeIdPair.id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3438,8 +3452,8 @@ static void _svgLoaderParserXmlCssStyle(SvgLoaderData* loader, const char* conte
|
||||
length -= next - content;
|
||||
content = next;
|
||||
|
||||
free(tag);
|
||||
free(name);
|
||||
lv_free(tag);
|
||||
lv_free(name);
|
||||
}
|
||||
loader->openedTag = OpenedTagType::Other;
|
||||
}
|
||||
@@ -3580,7 +3594,7 @@ static void _updateGradient(SvgLoaderData* loader, SvgNode* node, Array<SvgStyle
|
||||
if (newGrad) {
|
||||
if (node->style->fill.paint.gradient) {
|
||||
node->style->fill.paint.gradient->clear();
|
||||
free(node->style->fill.paint.gradient);
|
||||
lv_free(node->style->fill.paint.gradient);
|
||||
}
|
||||
node->style->fill.paint.gradient = newGrad;
|
||||
}
|
||||
@@ -3590,7 +3604,7 @@ static void _updateGradient(SvgLoaderData* loader, SvgNode* node, Array<SvgStyle
|
||||
if (newGrad) {
|
||||
if (node->style->stroke.paint.gradient) {
|
||||
node->style->stroke.paint.gradient->clear();
|
||||
free(node->style->stroke.paint.gradient);
|
||||
lv_free(node->style->stroke.paint.gradient);
|
||||
}
|
||||
node->style->stroke.paint.gradient = newGrad;
|
||||
}
|
||||
@@ -3623,22 +3637,22 @@ static void _freeNodeStyle(SvgStyleProperty* style)
|
||||
if (!style) return;
|
||||
|
||||
//style->clipPath.node and style->mask.node has only the addresses of node. Therefore, node is released from _freeNode.
|
||||
free(style->clipPath.url);
|
||||
free(style->mask.url);
|
||||
free(style->cssClass);
|
||||
lv_free(style->clipPath.url);
|
||||
lv_free(style->mask.url);
|
||||
lv_free(style->cssClass);
|
||||
|
||||
if (style->fill.paint.gradient) {
|
||||
style->fill.paint.gradient->clear();
|
||||
free(style->fill.paint.gradient);
|
||||
lv_free(style->fill.paint.gradient);
|
||||
}
|
||||
if (style->stroke.paint.gradient) {
|
||||
style->stroke.paint.gradient->clear();
|
||||
free(style->stroke.paint.gradient);
|
||||
lv_free(style->stroke.paint.gradient);
|
||||
}
|
||||
free(style->fill.paint.url);
|
||||
free(style->stroke.paint.url);
|
||||
lv_free(style->fill.paint.url);
|
||||
lv_free(style->stroke.paint.url);
|
||||
style->stroke.dash.array.reset();
|
||||
free(style);
|
||||
lv_free(style);
|
||||
}
|
||||
|
||||
|
||||
@@ -3652,20 +3666,20 @@ static void _freeNode(SvgNode* node)
|
||||
}
|
||||
node->child.reset();
|
||||
|
||||
free(node->id);
|
||||
free(node->transform);
|
||||
lv_free(node->id);
|
||||
lv_free(node->transform);
|
||||
_freeNodeStyle(node->style);
|
||||
switch (node->type) {
|
||||
case SvgNodeType::Path: {
|
||||
free(node->node.path.path);
|
||||
lv_free(node->node.path.path);
|
||||
break;
|
||||
}
|
||||
case SvgNodeType::Polygon: {
|
||||
free(node->node.polygon.pts.data);
|
||||
lv_free(node->node.polygon.pts.data);
|
||||
break;
|
||||
}
|
||||
case SvgNodeType::Polyline: {
|
||||
free(node->node.polyline.pts.data);
|
||||
lv_free(node->node.polyline.pts.data);
|
||||
break;
|
||||
}
|
||||
case SvgNodeType::Doc: {
|
||||
@@ -3677,26 +3691,26 @@ static void _freeNode(SvgNode* node)
|
||||
auto gradients = node->node.defs.gradients.data;
|
||||
for (size_t i = 0; i < node->node.defs.gradients.count; ++i) {
|
||||
(*gradients)->clear();
|
||||
free(*gradients);
|
||||
lv_free(*gradients);
|
||||
++gradients;
|
||||
}
|
||||
node->node.defs.gradients.reset();
|
||||
break;
|
||||
}
|
||||
case SvgNodeType::Image: {
|
||||
free(node->node.image.href);
|
||||
lv_free(node->node.image.href);
|
||||
break;
|
||||
}
|
||||
case SvgNodeType::Text: {
|
||||
free(node->node.text.text);
|
||||
free(node->node.text.fontFamily);
|
||||
lv_free(node->node.text.text);
|
||||
lv_free(node->node.text.fontFamily);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(node);
|
||||
lv_free(node);
|
||||
}
|
||||
|
||||
|
||||
@@ -3763,12 +3777,12 @@ static bool _svgLoaderParserForValidCheck(void* data, SimpleXMLType type, const
|
||||
void SvgLoader::clear(bool all)
|
||||
{
|
||||
//flush out the intermediate data
|
||||
free(loaderData.svgParse);
|
||||
lv_free(loaderData.svgParse);
|
||||
loaderData.svgParse = nullptr;
|
||||
|
||||
for (auto gradient = loaderData.gradients.begin(); gradient < loaderData.gradients.end(); ++gradient) {
|
||||
(*gradient)->clear();
|
||||
free(*gradient);
|
||||
lv_free(*gradient);
|
||||
}
|
||||
loaderData.gradients.reset();
|
||||
|
||||
@@ -3779,11 +3793,11 @@ void SvgLoader::clear(bool all)
|
||||
if (!all) return;
|
||||
|
||||
for (auto p = loaderData.images.begin(); p < loaderData.images.end(); ++p) {
|
||||
free(*p);
|
||||
lv_free(*p);
|
||||
}
|
||||
loaderData.images.reset();
|
||||
|
||||
if (copy) free((char*)content);
|
||||
if (copy) lv_free((char*)content);
|
||||
|
||||
delete(root);
|
||||
root = nullptr;
|
||||
@@ -3861,7 +3875,8 @@ bool SvgLoader::header()
|
||||
//For valid check, only <svg> tag is parsed first.
|
||||
//If the <svg> tag is found, the loaded file is valid and stores viewbox information.
|
||||
//After that, the remaining content data is parsed in order with async.
|
||||
loaderData.svgParse = (SvgParser*)malloc(sizeof(SvgParser));
|
||||
loaderData.svgParse = (SvgParser*)lv_malloc(sizeof(SvgParser));
|
||||
LV_ASSERT_MALLOC(loaderData.svgParse);
|
||||
if (!loaderData.svgParse) return false;
|
||||
|
||||
loaderData.svgParse->flags = SvgStopStyleFlags::StopDefault;
|
||||
@@ -3937,7 +3952,8 @@ bool SvgLoader::open(const char* data, uint32_t size, bool copy)
|
||||
clear();
|
||||
|
||||
if (copy) {
|
||||
content = (char*)malloc(size + 1);
|
||||
content = (char*)lv_malloc(size + 1);
|
||||
LV_ASSERT_MALLOC(content);
|
||||
if (!content) return false;
|
||||
memcpy((char*)content, data, size);
|
||||
content[size] = '\0';
|
||||
|
||||
@@ -459,11 +459,11 @@ struct SvgStyleGradient
|
||||
void clear()
|
||||
{
|
||||
stops.reset();
|
||||
free(transform);
|
||||
free(radial);
|
||||
free(linear);
|
||||
free(ref);
|
||||
free(id);
|
||||
lv_free(transform);
|
||||
lv_free(radial);
|
||||
lv_free(linear);
|
||||
lv_free(ref);
|
||||
lv_free(id);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -122,7 +122,8 @@ static unique_ptr<LinearGradient> _applyLinearGradientProperty(SvgStyleGradient*
|
||||
//Update the stops
|
||||
stopCount = g->stops.count;
|
||||
if (stopCount > 0) {
|
||||
stops = (Fill::ColorStop*)calloc(stopCount, sizeof(Fill::ColorStop));
|
||||
stops = (Fill::ColorStop*)lv_zalloc(stopCount * sizeof(Fill::ColorStop));
|
||||
LV_ASSERT_MALLOC(stops);
|
||||
if (!stops) return fillGrad;
|
||||
auto prevOffset = 0.0f;
|
||||
for (uint32_t i = 0; i < g->stops.count; ++i) {
|
||||
@@ -139,7 +140,7 @@ static unique_ptr<LinearGradient> _applyLinearGradientProperty(SvgStyleGradient*
|
||||
prevOffset = stops[i].offset;
|
||||
}
|
||||
fillGrad->colorStops(stops, stopCount);
|
||||
free(stops);
|
||||
lv_free(stops);
|
||||
}
|
||||
return fillGrad;
|
||||
}
|
||||
@@ -181,7 +182,8 @@ static unique_ptr<RadialGradient> _applyRadialGradientProperty(SvgStyleGradient*
|
||||
//Update the stops
|
||||
stopCount = g->stops.count;
|
||||
if (stopCount > 0) {
|
||||
stops = (Fill::ColorStop*)calloc(stopCount, sizeof(Fill::ColorStop));
|
||||
stops = (Fill::ColorStop*)lv_zalloc(stopCount * sizeof(Fill::ColorStop));
|
||||
LV_ASSERT_MALLOC(stops);
|
||||
if (!stops) return fillGrad;
|
||||
auto prevOffset = 0.0f;
|
||||
for (uint32_t i = 0; i < g->stops.count; ++i) {
|
||||
@@ -198,7 +200,7 @@ static unique_ptr<RadialGradient> _applyRadialGradientProperty(SvgStyleGradient*
|
||||
prevOffset = stops[i].offset;
|
||||
}
|
||||
fillGrad->colorStops(stops, stopCount);
|
||||
free(stops);
|
||||
lv_free(stops);
|
||||
}
|
||||
return fillGrad;
|
||||
}
|
||||
@@ -588,14 +590,14 @@ static unique_ptr<Picture> _imageBuildHelper(SvgLoaderData& loaderData, SvgNode*
|
||||
if (encoding == imageMimeTypeEncoding::base64) {
|
||||
auto size = b64Decode(href, strlen(href), &decoded);
|
||||
if (picture->load(decoded, size, mimetype, false) != Result::Success) {
|
||||
free(decoded);
|
||||
lv_free(decoded);
|
||||
TaskScheduler::async(true);
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
auto size = svgUtilURLDecode(href, &decoded);
|
||||
if (picture->load(decoded, size, mimetype, false) != Result::Success) {
|
||||
free(decoded);
|
||||
lv_free(decoded);
|
||||
TaskScheduler::async(true);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,8 @@ size_t svgUtilURLDecode(const char *src, char** dst)
|
||||
auto length = strlen(src);
|
||||
if (length == 0) return 0;
|
||||
|
||||
char* decoded = (char*)malloc(sizeof(char) * length + 1);
|
||||
char* decoded = (char*)lv_malloc(sizeof(char) * length + 1);
|
||||
LV_ASSERT_MALLOC(decoded);
|
||||
|
||||
char a, b;
|
||||
int idx =0;
|
||||
|
||||
@@ -131,7 +131,8 @@ static bool _updateColorTable(SwFill* fill, const Fill* fdata, const SwSurface*
|
||||
if (fill->solid) return true;
|
||||
|
||||
if (!fill->ctable) {
|
||||
fill->ctable = static_cast<uint32_t*>(malloc(GRADIENT_STOP_SIZE * sizeof(uint32_t)));
|
||||
fill->ctable = static_cast<uint32_t*>(lv_malloc(GRADIENT_STOP_SIZE * sizeof(uint32_t)));
|
||||
LV_ASSERT_MALLOC(fill->ctable);
|
||||
if (!fill->ctable) return false;
|
||||
}
|
||||
|
||||
@@ -857,7 +858,7 @@ const Fill::ColorStop* fillFetchSolid(const SwFill* fill, const Fill* fdata)
|
||||
void fillReset(SwFill* fill)
|
||||
{
|
||||
if (fill->ctable) {
|
||||
free(fill->ctable);
|
||||
lv_free(fill->ctable);
|
||||
fill->ctable = nullptr;
|
||||
}
|
||||
fill->translucent = false;
|
||||
@@ -869,9 +870,9 @@ void fillFree(SwFill* fill)
|
||||
{
|
||||
if (!fill) return;
|
||||
|
||||
if (fill->ctable) free(fill->ctable);
|
||||
if (fill->ctable) lv_free(fill->ctable);
|
||||
|
||||
free(fill);
|
||||
lv_free(fill);
|
||||
}
|
||||
|
||||
#endif /* LV_USE_THORVG_INTERNAL */
|
||||
|
||||
@@ -84,10 +84,14 @@ SwMpool* mpoolInit(uint32_t threads)
|
||||
{
|
||||
auto allocSize = threads + 1;
|
||||
|
||||
auto mpool = static_cast<SwMpool*>(calloc(1, sizeof(SwMpool)));
|
||||
mpool->outline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline) * allocSize));
|
||||
mpool->strokeOutline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline) * allocSize));
|
||||
mpool->dashOutline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline) * allocSize));
|
||||
auto mpool = static_cast<SwMpool*>(lv_zalloc(sizeof(SwMpool)));
|
||||
LV_ASSERT_MALLOC(mpool);
|
||||
mpool->outline = static_cast<SwOutline*>(lv_zalloc(sizeof(SwOutline) * allocSize));
|
||||
LV_ASSERT_MALLOC(mpool->outline);
|
||||
mpool->strokeOutline = static_cast<SwOutline*>(lv_zalloc(sizeof(SwOutline) * allocSize));
|
||||
LV_ASSERT_MALLOC(mpool->strokeOutline);
|
||||
mpool->dashOutline = static_cast<SwOutline*>(lv_zalloc(sizeof(SwOutline) * allocSize));
|
||||
LV_ASSERT_MALLOC(mpool->dashOutline);
|
||||
mpool->allocSize = allocSize;
|
||||
|
||||
return mpool;
|
||||
@@ -123,10 +127,10 @@ bool mpoolTerm(SwMpool* mpool)
|
||||
|
||||
mpoolClear(mpool);
|
||||
|
||||
free(mpool->outline);
|
||||
free(mpool->strokeOutline);
|
||||
free(mpool->dashOutline);
|
||||
free(mpool);
|
||||
lv_free(mpool->outline);
|
||||
lv_free(mpool->strokeOutline);
|
||||
lv_free(mpool->dashOutline);
|
||||
lv_free(mpool);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,8 @@ static int _gaussianInit(int* kernel, float sigma, int level)
|
||||
|
||||
bool effectGaussianPrepare(RenderEffectGaussian* params)
|
||||
{
|
||||
auto data = (SwGaussianBlur*)malloc(sizeof(SwGaussianBlur));
|
||||
auto data = (SwGaussianBlur*)lv_malloc(sizeof(SwGaussianBlur));
|
||||
LV_ASSERT_MALLOC(data);
|
||||
|
||||
//compute box kernel sizes
|
||||
data->level = int(SwGaussianBlur::MAX_LEVEL * ((params->quality - 1) * 0.01f)) + 1;
|
||||
@@ -140,7 +141,7 @@ bool effectGaussianPrepare(RenderEffectGaussian* params)
|
||||
//skip, if the parameters are invalid.
|
||||
if (extends == 0) {
|
||||
params->invalid = true;
|
||||
free(data);
|
||||
lv_free(data);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -831,14 +831,16 @@ static AASpans* _AASpans(float ymin, float ymax, const SwImage* image, const SwB
|
||||
|
||||
if (!_arrange(image, region, yStart, yEnd)) return nullptr;
|
||||
|
||||
auto aaSpans = static_cast<AASpans*>(malloc(sizeof(AASpans)));
|
||||
auto aaSpans = static_cast<AASpans*>(lv_malloc(sizeof(AASpans)));
|
||||
LV_ASSERT_MALLOC(aaSpans);
|
||||
aaSpans->yStart = yStart;
|
||||
aaSpans->yEnd = yEnd;
|
||||
|
||||
//Initialize X range
|
||||
auto height = yEnd - yStart;
|
||||
|
||||
aaSpans->lines = static_cast<AALine*>(malloc(height * sizeof(AALine)));
|
||||
aaSpans->lines = static_cast<AALine*>(lv_malloc(height * sizeof(AALine)));
|
||||
LV_ASSERT_MALLOC(aaSpans->lines);
|
||||
|
||||
for (int32_t i = 0; i < height; i++) {
|
||||
aaSpans->lines[i].x[0] = INT32_MAX;
|
||||
@@ -1094,8 +1096,8 @@ static bool _apply(SwSurface* surface, AASpans* aaSpans)
|
||||
y++;
|
||||
}
|
||||
|
||||
free(aaSpans->lines);
|
||||
free(aaSpans);
|
||||
lv_free(aaSpans->lines);
|
||||
lv_free(aaSpans);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ void SwRenderer::clearCompositors()
|
||||
{
|
||||
//Free Composite Caches
|
||||
for (auto comp = compositors.begin(); comp < compositors.end(); ++comp) {
|
||||
free((*comp)->compositor->image.data);
|
||||
lv_free((*comp)->compositor->image.data);
|
||||
delete((*comp)->compositor);
|
||||
delete(*comp);
|
||||
}
|
||||
@@ -566,7 +566,8 @@ SwSurface* SwRenderer::request(int channelSize)
|
||||
//Inherits attributes from main surface
|
||||
cmp = new SwSurface(surface);
|
||||
cmp->compositor = new SwCompositor;
|
||||
cmp->compositor->image.data = (pixel_t*)malloc(channelSize * surface->stride * surface->h);
|
||||
cmp->compositor->image.data = (pixel_t*)lv_malloc(channelSize * surface->stride * surface->h);
|
||||
LV_ASSERT_MALLOC(cmp->compositor->image.data);
|
||||
cmp->compositor->image.w = surface->w;
|
||||
cmp->compositor->image.h = surface->h;
|
||||
cmp->compositor->image.stride = surface->stride;
|
||||
@@ -701,7 +702,7 @@ void* SwRenderer::prepareCommon(SwTask* task, const Matrix& transform, const Arr
|
||||
|
||||
task->clips = clips;
|
||||
task->transform = transform;
|
||||
|
||||
|
||||
//zero size?
|
||||
if (task->transform.e11 == 0.0f && task->transform.e12 == 0.0f) return task; //zero width
|
||||
if (task->transform.e21 == 0.0f && task->transform.e22 == 0.0f) return task; //zero height
|
||||
|
||||
@@ -359,10 +359,11 @@ static void _horizLine(RleWorker& rw, SwCoord x, SwCoord y, SwCoord area, SwCoor
|
||||
auto newSize = (rle->size > 0) ? (rle->size * 2) : 256;
|
||||
if (rle->alloc < newSize) {
|
||||
rle->alloc = newSize;
|
||||
rle->spans = static_cast<SwSpan*>(realloc(rle->spans, rle->alloc * sizeof(SwSpan)));
|
||||
rle->spans = static_cast<SwSpan*>(lv_realloc(rle->spans, rle->alloc * sizeof(SwSpan)));
|
||||
LV_ASSERT_MALLOC(rle->spans);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Clip x range
|
||||
SwCoord xOver = 0;
|
||||
if (x + aCount >= rw.cellMax.x) xOver -= (x + aCount - rw.cellMax.x);
|
||||
@@ -842,7 +843,7 @@ static SwSpan* _intersectSpansRect(const SwBBox *bbox, const SwRle *targetRle, S
|
||||
|
||||
void _replaceClipSpan(SwRle *rle, SwSpan* clippedSpans, uint32_t size)
|
||||
{
|
||||
free(rle->spans);
|
||||
lv_free(rle->spans);
|
||||
rle->spans = clippedSpans;
|
||||
rle->size = rle->alloc = size;
|
||||
}
|
||||
@@ -880,7 +881,10 @@ SwRle* rleRender(SwRle* rle, const SwOutline* outline, const SwBBox& renderRegio
|
||||
rw.bandShoot = 0;
|
||||
rw.antiAlias = antiAlias;
|
||||
|
||||
if (!rle) rw.rle = reinterpret_cast<SwRle*>(calloc(1, sizeof(SwRle)));
|
||||
if (!rle) {
|
||||
rw.rle = reinterpret_cast<SwRle*>(lv_zalloc(sizeof(SwRle)));
|
||||
LV_ASSERT_MALLOC(rw.rle);
|
||||
}
|
||||
else rw.rle = rle;
|
||||
|
||||
//Generate RLE
|
||||
@@ -966,7 +970,7 @@ SwRle* rleRender(SwRle* rle, const SwOutline* outline, const SwBBox& renderRegio
|
||||
return rw.rle;
|
||||
|
||||
error:
|
||||
free(rw.rle);
|
||||
lv_free(rw.rle);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -976,8 +980,10 @@ SwRle* rleRender(const SwBBox* bbox)
|
||||
auto width = static_cast<uint16_t>(bbox->max.x - bbox->min.x);
|
||||
auto height = static_cast<uint16_t>(bbox->max.y - bbox->min.y);
|
||||
|
||||
auto rle = static_cast<SwRle*>(malloc(sizeof(SwRle)));
|
||||
rle->spans = static_cast<SwSpan*>(malloc(sizeof(SwSpan) * height));
|
||||
auto rle = static_cast<SwRle*>(lv_malloc(sizeof(SwRle)));
|
||||
LV_ASSERT_MALLOC(rle);
|
||||
rle->spans = static_cast<SwSpan*>(lv_malloc(sizeof(SwSpan) * height));
|
||||
LV_ASSERT_MALLOC(rle->spans);
|
||||
rle->size = height;
|
||||
rle->alloc = height;
|
||||
|
||||
@@ -1003,8 +1009,8 @@ void rleReset(SwRle* rle)
|
||||
void rleFree(SwRle* rle)
|
||||
{
|
||||
if (!rle) return;
|
||||
if (rle->spans) free(rle->spans);
|
||||
free(rle);
|
||||
if (rle->spans) lv_free(rle->spans);
|
||||
lv_free(rle);
|
||||
}
|
||||
|
||||
|
||||
@@ -1012,7 +1018,8 @@ void rleClip(SwRle *rle, const SwRle *clip)
|
||||
{
|
||||
if (rle->size == 0 || clip->size == 0) return;
|
||||
auto spanCnt = rle->size > clip->size ? rle->size : clip->size;
|
||||
auto spans = static_cast<SwSpan*>(malloc(sizeof(SwSpan) * (spanCnt)));
|
||||
auto spans = static_cast<SwSpan*>(lv_malloc(sizeof(SwSpan) * (spanCnt)));
|
||||
LV_ASSERT_MALLOC(spans);
|
||||
auto spansEnd = _intersectSpansRegion(clip, rle, spans, spanCnt);
|
||||
|
||||
_replaceClipSpan(rle, spans, spansEnd - spans);
|
||||
@@ -1024,7 +1031,8 @@ void rleClip(SwRle *rle, const SwRle *clip)
|
||||
void rleClip(SwRle *rle, const SwBBox* clip)
|
||||
{
|
||||
if (rle->size == 0) return;
|
||||
auto spans = static_cast<SwSpan*>(malloc(sizeof(SwSpan) * (rle->size)));
|
||||
auto spans = static_cast<SwSpan*>(lv_malloc(sizeof(SwSpan) * (rle->size)));
|
||||
LV_ASSERT_MALLOC(spans);
|
||||
auto spansEnd = _intersectSpansRect(clip, rle, spans, rle->size);
|
||||
|
||||
_replaceClipSpan(rle, spans, spansEnd - spans);
|
||||
|
||||
@@ -75,7 +75,7 @@ static void _outlineCubicTo(SwOutline& outline, const Point* ctrl1, const Point*
|
||||
outline.types.push(SW_CURVE_TYPE_CUBIC);
|
||||
|
||||
outline.pts.push(mathTransform(ctrl2, transform));
|
||||
outline.types.push(SW_CURVE_TYPE_CUBIC);
|
||||
outline.types.push(SW_CURVE_TYPE_CUBIC);
|
||||
|
||||
outline.pts.push(mathTransform(to, transform));
|
||||
outline.types.push(SW_CURVE_TYPE_POINT);
|
||||
@@ -347,7 +347,10 @@ static SwOutline* _genDashOutline(const RenderShape* rshape, const Matrix& trans
|
||||
if (trimmed) rshape->stroke->strokeTrim(trimBegin, trimEnd);
|
||||
|
||||
if (dash.cnt == 0) {
|
||||
if (trimmed) dash.pattern = (float*)malloc(sizeof(float) * 4);
|
||||
if (trimmed) {
|
||||
dash.pattern = (float*)lv_malloc(sizeof(float) * 4);
|
||||
LV_ASSERT_MALLOC(dash.pattern);
|
||||
}
|
||||
else return nullptr;
|
||||
} else {
|
||||
//TODO: handle dash + trim - for now trimming ignoring is forced
|
||||
@@ -414,7 +417,7 @@ static SwOutline* _genDashOutline(const RenderShape* rshape, const Matrix& trans
|
||||
|
||||
_outlineEnd(*dash.outline);
|
||||
|
||||
if (trimmed) free(dash.pattern);
|
||||
if (trimmed) lv_free(dash.pattern);
|
||||
|
||||
return dash.outline;
|
||||
}
|
||||
@@ -580,7 +583,10 @@ void shapeDelStroke(SwShape* shape)
|
||||
|
||||
void shapeResetStroke(SwShape* shape, const RenderShape* rshape, const Matrix& transform)
|
||||
{
|
||||
if (!shape->stroke) shape->stroke = static_cast<SwStroke*>(calloc(1, sizeof(SwStroke)));
|
||||
if (!shape->stroke) {
|
||||
shape->stroke = static_cast<SwStroke*>(lv_zalloc(sizeof(SwStroke)));
|
||||
LV_ASSERT_MALLOC(shape->stroke);
|
||||
}
|
||||
auto stroke = shape->stroke;
|
||||
if (!stroke) return;
|
||||
|
||||
@@ -647,7 +653,8 @@ bool shapeGenStrokeFillColors(SwShape* shape, const Fill* fill, const Matrix& tr
|
||||
void shapeResetFill(SwShape* shape)
|
||||
{
|
||||
if (!shape->fill) {
|
||||
shape->fill = static_cast<SwFill*>(calloc(1, sizeof(SwFill)));
|
||||
shape->fill = static_cast<SwFill*>(lv_zalloc(sizeof(SwFill)));
|
||||
LV_ASSERT_MALLOC(shape->fill);
|
||||
if (!shape->fill) return;
|
||||
}
|
||||
fillReset(shape->fill);
|
||||
@@ -657,7 +664,8 @@ void shapeResetFill(SwShape* shape)
|
||||
void shapeResetStrokeFill(SwShape* shape)
|
||||
{
|
||||
if (!shape->stroke->fill) {
|
||||
shape->stroke->fill = static_cast<SwFill*>(calloc(1, sizeof(SwFill)));
|
||||
shape->stroke->fill = static_cast<SwFill*>(lv_zalloc(sizeof(SwFill)));
|
||||
LV_ASSERT_MALLOC(shape->stroke->fill);
|
||||
if (!shape->stroke->fill) return;
|
||||
}
|
||||
fillReset(shape->stroke->fill);
|
||||
|
||||
@@ -61,8 +61,10 @@ static void _growBorder(SwStrokeBorder* border, uint32_t newPts)
|
||||
while (maxCur < maxNew)
|
||||
maxCur += (maxCur >> 1) + 16;
|
||||
//OPTIMIZE: use mempool!
|
||||
border->pts = static_cast<SwPoint*>(realloc(border->pts, maxCur * sizeof(SwPoint)));
|
||||
border->tags = static_cast<uint8_t*>(realloc(border->tags, maxCur * sizeof(uint8_t)));
|
||||
border->pts = static_cast<SwPoint*>(lv_realloc(border->pts, maxCur * sizeof(SwPoint)));
|
||||
LV_ASSERT_MALLOC(border->pts);
|
||||
border->tags = static_cast<uint8_t*>(lv_realloc(border->tags, maxCur * sizeof(uint8_t)));
|
||||
LV_ASSERT_MALLOC(border->tags);
|
||||
border->maxPts = maxCur;
|
||||
}
|
||||
|
||||
@@ -806,15 +808,15 @@ void strokeFree(SwStroke* stroke)
|
||||
if (!stroke) return;
|
||||
|
||||
//free borders
|
||||
if (stroke->borders[0].pts) free(stroke->borders[0].pts);
|
||||
if (stroke->borders[0].tags) free(stroke->borders[0].tags);
|
||||
if (stroke->borders[1].pts) free(stroke->borders[1].pts);
|
||||
if (stroke->borders[1].tags) free(stroke->borders[1].tags);
|
||||
if (stroke->borders[0].pts) lv_free(stroke->borders[0].pts);
|
||||
if (stroke->borders[0].tags) lv_free(stroke->borders[0].tags);
|
||||
if (stroke->borders[1].pts) lv_free(stroke->borders[1].pts);
|
||||
if (stroke->borders[1].tags) lv_free(stroke->borders[1].tags);
|
||||
|
||||
fillFree(stroke->fill);
|
||||
stroke->fill = nullptr;
|
||||
|
||||
free(stroke);
|
||||
lv_free(stroke);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,15 +47,15 @@ struct Text::Impl
|
||||
|
||||
~Impl()
|
||||
{
|
||||
free(utf8);
|
||||
lv_free(utf8);
|
||||
LoaderMgr::retrieve(loader);
|
||||
delete(shape);
|
||||
}
|
||||
|
||||
Result text(const char* utf8)
|
||||
{
|
||||
free(this->utf8);
|
||||
if (utf8) this->utf8 = strdup(utf8);
|
||||
lv_free(this->utf8);
|
||||
if (utf8) this->utf8 = lv_strdup(utf8);
|
||||
else this->utf8 = nullptr;
|
||||
changed = true;
|
||||
|
||||
@@ -157,7 +157,7 @@ struct Text::Impl
|
||||
++dup->loader->sharing;
|
||||
}
|
||||
|
||||
dup->utf8 = strdup(utf8);
|
||||
dup->utf8 = lv_strdup(utf8);
|
||||
dup->italic = italic;
|
||||
dup->fontSize = fontSize;
|
||||
|
||||
|
||||
@@ -301,7 +301,8 @@ bool isIgnoreUnsupportedLogElements(TVG_UNUSED const char* tagName)
|
||||
bool simpleXmlParseAttributes(const char* buf, unsigned bufLength, simpleXMLAttributeCb func, const void* data)
|
||||
{
|
||||
const char *itr = buf, *itrEnd = buf + bufLength;
|
||||
char* tmpBuf = (char*)malloc(bufLength + 1);
|
||||
char* tmpBuf = (char*)lv_malloc(bufLength + 1);
|
||||
LV_ASSERT_MALLOC(tmpBuf);
|
||||
|
||||
if (!buf || !func || !tmpBuf) goto error;
|
||||
|
||||
@@ -366,11 +367,11 @@ bool simpleXmlParseAttributes(const char* buf, unsigned bufLength, simpleXMLAttr
|
||||
}
|
||||
|
||||
success:
|
||||
free(tmpBuf);
|
||||
lv_free(tmpBuf);
|
||||
return true;
|
||||
|
||||
error:
|
||||
free(tmpBuf);
|
||||
lv_free(tmpBuf);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -564,7 +565,7 @@ const char* simpleXmlParseCSSAttribute(const char* buf, unsigned bufLength, char
|
||||
if (*p == '.') break;
|
||||
}
|
||||
|
||||
if (p == itr) *tag = strdup("all");
|
||||
if (p == itr) *tag = lv_strdup("all");
|
||||
else *tag = strDuplicate(itr, p - itr);
|
||||
|
||||
if (p == itrEnd) *name = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user