fix: xml memory leaks using arena

This commit is contained in:
Simon Hartcher 2025-04-23 16:39:04 +10:00
parent bc328e72ad
commit 0fe727c7eb

View file

@ -646,7 +646,13 @@ pub fn Request(comptime request_action: anytype) type {
// } // }
// //
// Big thing is that requestid, which we'll need to fetch "manually" // Big thing is that requestid, which we'll need to fetch "manually"
const xml_options = xml_shaper.ParseOptions{ .allocator = options.client.allocator, .elementToParse = findResult }; var arena = ArenaAllocator.init(options.client.allocator);
const xml_options = xml_shaper.ParseOptions{
.allocator = arena.allocator(),
.elementToParse = findResult,
};
var body: []const u8 = result.body; var body: []const u8 = result.body;
var free_body = false; var free_body = false;
if (result.body.len < 20) { if (result.body.len < 20) {
@ -677,12 +683,13 @@ pub fn Request(comptime request_action: anytype) type {
}; };
return try FullResponseType.init(.{ return try FullResponseType.init(.{
.arena = ArenaAllocator.init(options.client.allocator), .arena = arena,
.response = parsed.parsed_value, .response = parsed.parsed_value,
.request_id = request_id, .request_id = request_id,
.raw_parsed = .{ .xml = parsed }, .raw_parsed = .{ .xml = parsed },
}); });
} }
const ServerResponseTypes = struct { const ServerResponseTypes = struct {
NormalResponse: type, NormalResponse: type,
RawResponse: type, RawResponse: type,