[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 05/10] json-lexer: make it safe to call destroy m
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH v4 05/10] json-lexer: make it safe to call destroy multiple times |
Date: |
Wed, 29 Aug 2018 15:40:38 +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 the qmp-async RFC
series, the patch "qmp: add QmpSession" can call qmp_session_destroy()
multiple time, which in turns calls json_lexer_destroy().
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 e1745a3d95..39969047f4 100644
--- a/qobject/json-lexer.c
+++ b/qobject/json-lexer.c
@@ -351,5 +351,8 @@ void 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.19.0.rc0.48.gb9dfa238d5
- [Qemu-devel] [PATCH v4 00/10] monitor: various code simplification and fixes, Marc-André Lureau, 2018/08/29
- [Qemu-devel] [PATCH v4 02/10] qmp: constify qmp_is_oob(), Marc-André Lureau, 2018/08/29
- [Qemu-devel] [PATCH v4 01/10] monitor: consitify qmp_send_response() QDict argument, Marc-André Lureau, 2018/08/29
- [Qemu-devel] [PATCH v4 03/10] Revert "qmp: isolate responses into io thread", Marc-André Lureau, 2018/08/29
- [Qemu-devel] [PATCH v4 04/10] monitor: no need to save need_resume, Marc-André Lureau, 2018/08/29
- [Qemu-devel] [PATCH v4 05/10] json-lexer: make it safe to call destroy multiple times,
Marc-André Lureau <=
- [Qemu-devel] [PATCH v4 06/10] tests: add qmp/object-add-without-props test, Marc-André Lureau, 2018/08/29
- [Qemu-devel] [PATCH v4 08/10] tests: add a qmp success-response test, Marc-André Lureau, 2018/08/29
- [Qemu-devel] [PATCH v4 07/10] tests: add qmp/qom-set-without-value test, Marc-André Lureau, 2018/08/29