Ver código fonte

Made sure temp guard for sorting map keys in json marshal code ignores temp allocator

Karl Zylinski 1 ano atrás
pai
commit
9d067ae562
1 arquivos alterados com 3 adições e 3 exclusões
  1. 3 3
      core/encoding/json/marshal.odin

+ 3 - 3
core/encoding/json/marshal.odin

@@ -62,6 +62,9 @@ marshal :: proc(v: any, opt: Marshal_Options = {}, allocator := context.allocato
 	defer if err != nil {
 	defer if err != nil {
 		strings.builder_destroy(&b)
 		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
 	opt := opt
 	marshal_to_builder(&b, v, &opt) or_return
 	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
 		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))
 	ti := runtime.type_info_base(type_info_of(v.id))
 	a := any{v.data, ti.id}
 	a := any{v.data, ti.id}