[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 14/18] json-lexer: make it safe to call multiple
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH v2 14/18] json-lexer: make it safe to call multiple times |
Date: |
Thu, 19 Jul 2018 20:41:07 +0200 |
We can easily avoid the burden of checking if the lexer was
initialized prior to calling destroy by the caller, let's do it.
This allows simplification in state tracking in later patches of the
qmp-async RFC series.
Signed-off-by: Marc-André Lureau <address@hidden>
---
qobject/json-lexer.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/qobject/json-lexer.c b/qobject/json-lexer.c
index 980ba159d6..0eaba43a2c 100644
--- a/qobject/json-lexer.c
+++ b/qobject/json-lexer.c
@@ -386,5 +386,8 @@ int json_lexer_flush(JSONLexer *lexer)
void json_lexer_destroy(JSONLexer *lexer)
{
- g_string_free(lexer->token, true);
+ if (lexer->token) {
+ g_string_free(lexer->token, true);
+ lexer->token = NULL;
+ }
}
--
2.18.0.129.ge3331758f1
- Re: [Qemu-devel] [PATCH v2 10/18] qjson: report an error if there are multiple results, (continued)
- [Qemu-devel] [PATCH v2 09/18] json-parser: further simplify freeing JSONParserContext, Marc-André Lureau, 2018/07/19
- [Qemu-devel] [PATCH v2 06/18] qga: process_event() simplification and leak fix, Marc-André Lureau, 2018/07/19
- [Qemu-devel] [PATCH v2 07/18] qmp: drop json_parser_parse() wrapper, Marc-André Lureau, 2018/07/19
- [Qemu-devel] [PATCH v2 13/18] json-parser: set an error if parsing returned NULL, Marc-André Lureau, 2018/07/19
- [Qemu-devel] [PATCH v2 15/18] tests: add a few qemu-qmp tests, Marc-André Lureau, 2018/07/19
- [Qemu-devel] [PATCH v2 14/18] json-lexer: make it safe to call multiple times,
Marc-André Lureau <=
- [Qemu-devel] [PATCH v2 12/18] qjson: return parsing error if unterminated input, Marc-André Lureau, 2018/07/19
- [Qemu-devel] [PATCH v2 18/18] RFC: qmp: common 'id' handling & make QGA conform to QMP spec, Marc-André Lureau, 2018/07/19
- [Qemu-devel] [PATCH v2 16/18] tests: add a qmp success-response test, Marc-André Lureau, 2018/07/19
- [Qemu-devel] [PATCH v2 17/18] qga: process_event() simplification, Marc-André Lureau, 2018/07/19