aboutsummaryrefslogtreecommitdiff
path: root/core/encoding
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2024-05-30 11:42:34 +0200
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-02 14:47:08 -0400
commit3404dea8ac741f98e3de4a341f64ef37d06550d9 (patch)
treee2a386ae11e40bd6c1541e0482402c18c93ffa32 /core/encoding
parent40b20fb47353e61681ef815c43423d76b99e61d9 (diff)
Port `tests\encoding\hex`
Diffstat (limited to 'core/encoding')
-rw-r--r--core/encoding/hex/hex.odin11
1 files changed, 5 insertions, 6 deletions
diff --git a/core/encoding/hex/hex.odin b/core/encoding/hex/hex.odin
index dbffe216b..c2cd89c5b 100644
--- a/core/encoding/hex/hex.odin
+++ b/core/encoding/hex/hex.odin
@@ -2,8 +2,8 @@ package encoding_hex
import "core:strings"
-encode :: proc(src: []byte, allocator := context.allocator) -> []byte #no_bounds_check {
- dst := make([]byte, len(src) * 2, allocator)
+encode :: proc(src: []byte, allocator := context.allocator, loc := #caller_location) -> []byte #no_bounds_check {
+ dst := make([]byte, len(src) * 2, allocator, loc)
for i, j := 0, 0; i < len(src); i += 1 {
v := src[i]
dst[j] = HEXTABLE[v>>4]
@@ -15,12 +15,12 @@ encode :: proc(src: []byte, allocator := context.allocator) -> []byte #no_bounds
}
-decode :: proc(src: []byte, allocator := context.allocator) -> (dst: []byte, ok: bool) #no_bounds_check {
+decode :: proc(src: []byte, allocator := context.allocator, loc := #caller_location) -> (dst: []byte, ok: bool) #no_bounds_check {
if len(src) % 2 == 1 {
return
}
- dst = make([]byte, len(src) / 2, allocator)
+ dst = make([]byte, len(src) / 2, allocator, loc)
for i, j := 0, 1; j < len(src); j += 2 {
p := src[j-1]
q := src[j]
@@ -69,5 +69,4 @@ hex_digit :: proc(char: byte) -> (u8, bool) {
case 'A' ..= 'F': return char - 'A' + 10, true
case: return 0, false
}
-}
-
+} \ No newline at end of file