aboutsummaryrefslogtreecommitdiff
path: root/core/encoding
diff options
context:
space:
mode:
authorKarl Zylinski <karl@zylinski.se>2024-01-22 14:35:05 +0100
committerKarl Zylinski <karl@zylinski.se>2024-01-22 14:35:05 +0100
commit9d067ae562d60ae3e0eb29770693d6fc26e793f1 (patch)
tree93cb952c2943ad1ef20017a7b7cafd107af1f772 /core/encoding
parent75cb2c68cc1f75760d39cd7a41f91d65496843dd (diff)
Made sure temp guard for sorting map keys in json marshal code ignores temp allocator
Diffstat (limited to 'core/encoding')
-rw-r--r--core/encoding/json/marshal.odin6
1 files changed, 3 insertions, 3 deletions
diff --git a/core/encoding/json/marshal.odin b/core/encoding/json/marshal.odin
index 9ef78b95d..ab2af9561 100644
--- a/core/encoding/json/marshal.odin
+++ b/core/encoding/json/marshal.odin
@@ -62,6 +62,9 @@ marshal :: proc(v: any, opt: Marshal_Options = {}, allocator := context.allocato
defer if err != nil {
strings.builder_destroy(&b)
}
+
+ // temp guard in case we are sorting map keys, which will use temp allocations
+ runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = allocator == context.temp_allocator)
opt := opt
marshal_to_builder(&b, v, &opt) or_return
@@ -83,9 +86,6 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
return
}
- // temp guard in case we are sorting map keys, which will use temp allocations
- runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
-
ti := runtime.type_info_base(type_info_of(v.id))
a := any{v.data, ti.id}