mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-08 08:38:51 +00:00
Alignment + unnecessary allocator param.
This commit is contained in:
+6
-6
@@ -422,7 +422,7 @@ load_hosts :: proc(hosts_file_path: string, allocator := context.allocator) -> (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// www.google.com -> 3www6google3com0
|
// www.google.com -> 3www6google3com0
|
||||||
encode_hostname :: proc(b: ^strings.Builder, hostname: string, allocator := context.allocator) -> (ok: bool) {
|
encode_hostname :: proc(b: ^strings.Builder, hostname: string) -> (ok: bool) {
|
||||||
_hostname := hostname
|
_hostname := hostname
|
||||||
for section in strings.split_iterator(&_hostname, ".") {
|
for section in strings.split_iterator(&_hostname, ".") {
|
||||||
if len(section) > LABEL_MAX {
|
if len(section) > LABEL_MAX {
|
||||||
@@ -437,7 +437,7 @@ encode_hostname :: proc(b: ^strings.Builder, hostname: string, allocator := cont
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
skip_hostname :: proc(packet: []u8, start_idx: int, allocator := context.allocator) -> (encode_size: int, ok: bool) {
|
skip_hostname :: proc(packet: []u8, start_idx: int) -> (encode_size: int, ok: bool) {
|
||||||
out_size := 0
|
out_size := 0
|
||||||
|
|
||||||
cur_idx := start_idx
|
cur_idx := start_idx
|
||||||
@@ -690,9 +690,9 @@ parse_record :: proc(packet: []u8, cur_off: ^int, filter: DNS_Record_Type = nil)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
priority: u16be = mem.slice_data_cast([]u16be, data)[0]
|
_data := mem.slice_data_cast([]u16be, data)
|
||||||
weight: u16be = mem.slice_data_cast([]u16be, data)[1]
|
|
||||||
port: u16be = mem.slice_data_cast([]u16be, data)[2]
|
priority, weight, port := _data[0], _data[1], _data[2]
|
||||||
target, _ := decode_hostname(packet, data_off + (size_of(u16be) * 3)) or_return
|
target, _ := decode_hostname(packet, data_off + (size_of(u16be) * 3)) or_return
|
||||||
|
|
||||||
// NOTE(tetra): Srv record name should be of the form '_servicename._protocol.hostname'
|
// NOTE(tetra): Srv record name should be of the form '_servicename._protocol.hostname'
|
||||||
@@ -800,7 +800,7 @@ parse_response :: proc(response: []u8, filter: DNS_Record_Type = nil, allocator
|
|||||||
}
|
}
|
||||||
|
|
||||||
dq_sz :: 4
|
dq_sz :: 4
|
||||||
hn_sz := skip_hostname(response, cur_idx, context.temp_allocator) or_return
|
hn_sz := skip_hostname(response, cur_idx) or_return
|
||||||
dns_query := mem.slice_data_cast([]u16be, response[cur_idx+hn_sz:cur_idx+hn_sz+dq_sz])
|
dns_query := mem.slice_data_cast([]u16be, response[cur_idx+hn_sz:cur_idx+hn_sz+dq_sz])
|
||||||
|
|
||||||
cur_idx += hn_sz + dq_sz
|
cur_idx += hn_sz + dq_sz
|
||||||
|
|||||||
Reference in New Issue
Block a user