From 1fe49adba298aeb4d3c913b838ea4bf61b489fbf Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Thu, 26 Oct 2023 09:00:11 +0200 Subject: [PATCH] dom: add comment about buffer with fixed length The buffer is used for upper case string transformation. --- src/dom/html_collection.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/dom/html_collection.zig b/src/dom/html_collection.zig index 35068092..d1d09a85 100644 --- a/src/dom/html_collection.zig +++ b/src/dom/html_collection.zig @@ -27,6 +27,11 @@ pub const HTMLCollection = struct { var node: ?*parser.Node = self.root; var ntype: parser.NodeType = undefined; + // FIXME using a fixed length buffer here avoid the need of an allocator + // to get an upper case match value. But if the match value (a tag + // name) is greater than 128 chars, the code will panic. + // ascii.upperString asserts the buffer size is greater or equals than + // the given string. var buffer: [128]u8 = undefined; const imatch = std.ascii.upperString(&buffer, self.match); @@ -79,6 +84,11 @@ pub const HTMLCollection = struct { var is_wildcard = std.mem.eql(u8, self.match, "*"); + // FIXME using a fixed length buffer here avoid the need of an allocator + // to get an upper case match value. But if the match value (a tag + // name) is greater than 128 chars, the code will panic. + // ascii.upperString asserts the buffer size is greater or equals than + // the given string. var buffer: [128]u8 = undefined; const imatch = std.ascii.upperString(&buffer, self.match); @@ -137,6 +147,11 @@ pub const HTMLCollection = struct { var is_wildcard = std.mem.eql(u8, self.match, "*"); + // FIXME using a fixed length buffer here avoid the need of an allocator + // to get an upper case match value. But if the match value (a tag + // name) is greater than 128 chars, the code will panic. + // ascii.upperString asserts the buffer size is greater or equals than + // the given string. var buffer: [128]u8 = undefined; const imatch = std.ascii.upperString(&buffer, self.match);