From 7198bf5d800101a1c1120cdc46c12f350bc4babc Mon Sep 17 00:00:00 2001 From: FourteenBrush <74827262+FourteenBrush@users.noreply.github.com> Date: Sat, 29 Aug 2026 18:27:07 +0200 Subject: [PATCH 1/4] `net.split_url`: use explicitly passed allocator --- core/net/url.odin | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/net/url.odin b/core/net/url.odin index b5bd6d917..59a01d043 100644 --- a/core/net/url.odin +++ b/core/net/url.odin @@ -42,12 +42,12 @@ split_url :: proc(url: string, allocator := context.allocator) -> (scheme, host, query_str := s[i+1:] s = s[:i] if query_str != "" { - queries_parts := strings.split(query_str, "&") - defer delete(queries_parts) + queries_parts := strings.split(query_str, "&", allocator) + defer delete(queries_parts, allocator) queries = make(map[string]string, len(queries_parts), allocator) for q in queries_parts { - parts := strings.split(q, "=") - defer delete(parts) + parts := strings.split(q, "=", allocator) + defer delete(parts, allocator) switch len(parts) { case 1: queries[parts[0]] = "" // NOTE(tetra): Query not set to anything, was but present. case 2: queries[parts[0]] = parts[1] // NOTE(tetra): Query set to something. From af6bcc13d66bb97c14b2500c7230c3cab8d69d2b Mon Sep 17 00:00:00 2001 From: FourteenBrush <74827262+FourteenBrush@users.noreply.github.com> Date: Sat, 29 Aug 2026 18:56:08 +0200 Subject: [PATCH 2/4] `net.parse_record`: use explicitly passed allocator --- core/net/dns.odin | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/net/dns.odin b/core/net/dns.odin index 54cc57c38..919b391cc 100644 --- a/core/net/dns.odin +++ b/core/net/dns.odin @@ -620,7 +620,8 @@ validate_hostname :: proc(hostname: string) -> (ok: bool) { return true } -parse_record :: proc(packet: []u8, cur_off: ^int, filter: DNS_Record_Type = nil) -> (record: DNS_Record, ok: bool) { +parse_record :: proc(packet: []u8, cur_off: ^int, filter: DNS_Record_Type = nil, allocator := context.allocator) -> (record: DNS_Record, ok: bool) { + context.allocator = allocator record_buf := packet[cur_off^:] srv_record_name, hn_sz := decode_hostname(packet, cur_off^, context.temp_allocator) or_return From 57181d5c270b107e1d40a587500d816afb1802d5 Mon Sep 17 00:00:00 2001 From: FourteenBrush <74827262+FourteenBrush@users.noreply.github.com> Date: Sat, 29 Aug 2026 21:54:26 +0200 Subject: [PATCH 3/4] Avoid allocations in `net.split_url` --- core/net/url.odin | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/core/net/url.odin b/core/net/url.odin index 59a01d043..d2ac709cd 100644 --- a/core/net/url.odin +++ b/core/net/url.odin @@ -31,27 +31,28 @@ split_url :: proc(url: string, allocator := context.allocator) -> (scheme, host, s = s[i+3:] } - i = strings.index(s, "#") + i = strings.index_byte(s, '#') if i != -1 { fragment = s[i+1:] s = s[:i] } - i = strings.index(s, "?") + i = strings.index_byte(s, '?') if i != -1 { query_str := s[i+1:] s = s[:i] if query_str != "" { - queries_parts := strings.split(query_str, "&", allocator) - defer delete(queries_parts, allocator) - queries = make(map[string]string, len(queries_parts), allocator) - for q in queries_parts { - parts := strings.split(q, "=", allocator) - defer delete(parts, allocator) - switch len(parts) { - case 1: queries[parts[0]] = "" // NOTE(tetra): Query not set to anything, was but present. - case 2: queries[parts[0]] = parts[1] // NOTE(tetra): Query set to something. - case: break + queries = make(map[string]string, allocator) + for query in strings.split_iterator(&query_str, "&") { + i = strings.index_byte(query, '=') + if i == -1 { + queries[query] = "" + } else { + value := query[i+1:] + if strings.index_byte(value, '=') != -1 { + continue // incorrect format + } + queries[query] = value // may not be set to anything, e.g. ?x= } } } From a635f0ef91fc388c0a2ee4aa36462c5e45134e82 Mon Sep 17 00:00:00 2001 From: FourteenBrush <74827262+FourteenBrush@users.noreply.github.com> Date: Sat, 29 Aug 2026 22:39:15 +0200 Subject: [PATCH 4/4] `net.split_url`: fix length on query values --- core/net/url.odin | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/core/net/url.odin b/core/net/url.odin index d2ac709cd..9f71af79b 100644 --- a/core/net/url.odin +++ b/core/net/url.odin @@ -44,16 +44,13 @@ split_url :: proc(url: string, allocator := context.allocator) -> (scheme, host, if query_str != "" { queries = make(map[string]string, allocator) for query in strings.split_iterator(&query_str, "&") { - i = strings.index_byte(query, '=') - if i == -1 { - queries[query] = "" - } else { - value := query[i+1:] - if strings.index_byte(value, '=') != -1 { - continue // incorrect format - } - queries[query] = value // may not be set to anything, e.g. ?x= + query := query + key := strings.split_by_byte_iterator(&query, '=') or_continue + value, _ := strings.split_by_byte_iterator(&query, '=') // may be empty + if strings.index_byte(query, '=') != -1 { + continue // additional =, weird x=y=z format } + queries[key] = value } } }