1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 23:24:09 +00:00

fixed MustacheBuild mem leak

This commit is contained in:
Rene Schallner 2023-03-10 21:16:15 +01:00
parent 3cf802be4a
commit 86f44ac45b
2 changed files with 9 additions and 3 deletions

View file

@ -1,6 +1,6 @@
.{
.name = "zap",
.version = "0.0.5",
.version = "0.0.6",
.dependencies = .{
.@"facil.io" = .{

View file

@ -79,8 +79,12 @@ pub fn MustacheNew(data: []const u8) MustacheError!*Mustache {
const MustacheBuildResult = struct {
fiobj_result: fio.FIOBJ = 0,
/// holds the context converted into a fiobj, used in build
fiobj_context: fio.FIOBJ = 0,
pub fn deinit(m: *const MustacheBuildResult) void {
fio.fiobj_free_wrapped(m.fiobj_result);
fio.fiobj_free_wrapped(m.fiobj_context);
}
pub fn str(m: *const MustacheBuildResult) ?[]const u8 {
@ -96,9 +100,11 @@ pub fn MustacheBuild(mustache: *Mustache, data: anytype) MustacheBuildResult {
@compileError("No struct: '" ++ @typeName(T) ++ "'");
}
const fiobj_data = fiobjectify(data);
var result: MustacheBuildResult = .{};
return .{ .fiobj_result = fiobj_mustache_build(mustache, fiobj_data) };
result.fiobj_context = fiobjectify(data);
result.fiobj_result = fiobj_mustache_build(mustache, result.fiobj_context);
return result;
}
pub fn fiobjectify(