diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2023-12-20 16:20:33 +0100 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-03-04 17:26:19 +0100 |
| commit | 3fccc77829d6479b972026c5fee7ef0f34ac589e (patch) | |
| tree | 92aa91d3c9ada41fcab321baf499b31a31e240a7 /core/encoding/cbor/coding.odin | |
| parent | 85f1a60cf301abab292e1dab65e19c61c5612e8e (diff) | |
encoding/cbor: clean and fixup some allocations
Diffstat (limited to 'core/encoding/cbor/coding.odin')
| -rw-r--r-- | core/encoding/cbor/coding.odin | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/core/encoding/cbor/coding.odin b/core/encoding/cbor/coding.odin index 1e77a35c8..32ecf52bc 100644 --- a/core/encoding/cbor/coding.odin +++ b/core/encoding/cbor/coding.odin @@ -431,7 +431,9 @@ _decode_bytes_ptr :: proc(d: Decoder, add: Add, type: Major = .Bytes) -> (v: ^By return } -_decode_bytes :: proc(d: Decoder, add: Add, type: Major = .Bytes) -> (v: Bytes, err: Decode_Error) { +_decode_bytes :: proc(d: Decoder, add: Add, type: Major = .Bytes, allocator := context.allocator) -> (v: Bytes, err: Decode_Error) { + context.allocator = allocator + n, scap := _decode_len_str(d, add) or_return buf := strings.builder_make(0, scap) or_return @@ -487,8 +489,8 @@ _decode_text_ptr :: proc(d: Decoder, add: Add) -> (v: ^Text, err: Decode_Error) return } -_decode_text :: proc(d: Decoder, add: Add) -> (v: Text, err: Decode_Error) { - return (Text)(_decode_bytes(d, add, .Text) or_return), nil +_decode_text :: proc(d: Decoder, add: Add, allocator := context.temp_allocator) -> (v: Text, err: Decode_Error) { + return (Text)(_decode_bytes(d, add, .Text, allocator) or_return), nil } _encode_text :: proc(e: Encoder, val: Text) -> Encode_Error { |