From 7655490faafe5afd7f2a5e397db9c9d208b142ca Mon Sep 17 00:00:00 2001 From: Hitalo Souza Date: Sat, 19 Oct 2024 04:54:55 -0400 Subject: [PATCH] linked list free method --- vlib/x/json2/decoder2/decode.v | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vlib/x/json2/decoder2/decode.v b/vlib/x/json2/decoder2/decode.v index a52c2928230572..4aab38e41e5469 100644 --- a/vlib/x/json2/decoder2/decode.v +++ b/vlib/x/json2/decoder2/decode.v @@ -66,6 +66,16 @@ fn (list LinkedList) str() string { return result } +@[unsafe] +fn (list &LinkedList) free() { + mut current := list.head + for current != unsafe { nil } { + mut next := current.next + unsafe { free(current) } + current = next + } +} + // ValueKind represents the kind of a JSON value. pub enum ValueKind { unknown