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.
This commit is contained in:
Mira Grudzinska 2023-08-03 00:56:10 +02:00 committed by Hermet Park
parent 480917651a
commit 6ad4a0b180

View file

@ -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();
}
}