jsonfmt: Fix threading support + memory leak bug

This commit is contained in:
Yorhel 2025-01-28 19:19:18 +01:00
parent 9c8ce3f782
commit 12326ca8e4
5 changed files with 79 additions and 69 deletions

17
FU.xs
View file

@ -10,15 +10,10 @@ MODULE = FU PACKAGE = FU::XS
PROTOTYPES: DISABLE
SV *json_format(val)
SV *val
PREINIT:
SV *r;
fustr buf = {};
void json_format(SV *val)
CODE:
fujson_fmt(&buf, val);
r = fustr_sv(&buf);
SvUTF8_on(r);
RETVAL = r;
OUTPUT:
RETVAL
fustr buf;
fustr_init(&buf, 128);
fujson_fmt(aTHX_ &buf, val);
ST(0) = fustr_done(&buf);
SvUTF8_on(ST(0));