From 6ad4a0b1806abc0478e34c3c6e93b4212c27b992 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Thu, 3 Aug 2023 00:56:10 +0200 Subject: [PATCH] lottie_loader: custom strtof and strndup used The custom version of 'strtof' must be used because its result is dependent on the current locale, which is't set in the project. --- src/loaders/lottie/tvgLottieLoader.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/loaders/lottie/tvgLottieLoader.cpp b/src/loaders/lottie/tvgLottieLoader.cpp index 07aa5634..140da341 100644 --- a/src/loaders/lottie/tvgLottieLoader.cpp +++ b/src/loaders/lottie/tvgLottieLoader.cpp @@ -25,6 +25,7 @@ #include "tvgLottieModel.h" #include "tvgLottieParser.h" #include "tvgLottieBuilder.h" +#include "tvgStr.h" /************************************************************************/ /* Internal Class Implementation */ @@ -50,13 +51,8 @@ static int _str2int(const char* str, int len) static int _str2float(const char* str, int len) { - //strndup() - auto tmp = (char*)malloc(len + 1); - if (!tmp) return 0; - tmp[len] = '\0'; - memcpy(tmp, str, len); - - auto ret = strtof(tmp, nullptr); + auto tmp = strDuplicate(str, len); + auto ret = strToFloat(tmp, nullptr); free(tmp); return lround(ret); } @@ -325,4 +321,4 @@ float LottieLoader::duration() void LottieLoader::sync() { this->done(); -} \ No newline at end of file +}