From 95497626e3e86a1355c04554906df1f6bce88051 Mon Sep 17 00:00:00 2001 From: Igor Dreher Date: Fri, 24 Mar 2023 20:58:55 -0300 Subject: [PATCH 1/2] Add allocator parameter to `json.detroy_value` --- core/encoding/json/types.odin | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/encoding/json/types.odin b/core/encoding/json/types.odin index 468774aa9..e43659948 100644 --- a/core/encoding/json/types.odin +++ b/core/encoding/json/types.odin @@ -87,21 +87,21 @@ Error :: enum { -destroy_value :: proc(value: Value) { +destroy_value :: proc(value: Value, allocator := context.allocator) { #partial switch v in value { case Object: for key, elem in v { - delete(key) - destroy_value(elem) + delete(key, allocator) + destroy_value(elem, allocator) } delete(v) case Array: for elem in v { - destroy_value(elem) + destroy_value(elem, allocator) } delete(v) case String: - delete(v) + delete(v, allocator) } } From 4c13dee18f66df37d19188659d7573ab7a8e97c6 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sat, 25 Mar 2023 07:33:34 +0100 Subject: [PATCH 2/2] Update types.odin Use `context.allocator := allocator` idiom. --- core/encoding/json/types.odin | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/encoding/json/types.odin b/core/encoding/json/types.odin index e43659948..57daaafef 100644 --- a/core/encoding/json/types.odin +++ b/core/encoding/json/types.odin @@ -88,20 +88,20 @@ Error :: enum { destroy_value :: proc(value: Value, allocator := context.allocator) { + context.allocator := allocator #partial switch v in value { case Object: for key, elem in v { - delete(key, allocator) - destroy_value(elem, allocator) + delete(key) + destroy_value(elem) } delete(v) case Array: for elem in v { - destroy_value(elem, allocator) + destroy_value(elem) } delete(v) case String: - delete(v, allocator) + delete(v) } -} - +} \ No newline at end of file