aboutsummaryrefslogtreecommitdiff
path: root/qobject/json-streamer.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-11-25 22:23:29 +0100
committerMarkus Armbruster <armbru@redhat.com>2015-11-26 09:31:22 +0100
commitd2ca7c0b0d876cf0e219ae7a92252626b0913a28 (patch)
treeb3b33462ad5376ef9cc4a4b90415365fddbe0c73 /qobject/json-streamer.c
parent6b9606f68ec589def27bd2a9cea97ec63cffd581 (diff)
qjson: replace QString in JSONLexer with GString
JSONLexer only needs a simple resizable buffer. json-streamer.c can allocate memory for each token instead of relying on reference counting of QStrings. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <1448300659-23559-2-git-send-email-pbonzini@redhat.com> [Straightforwardly rebased on my patches, checkpatch made happy] Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'qobject/json-streamer.c')
-rw-r--r--qobject/json-streamer.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/qobject/json-streamer.c b/qobject/json-streamer.c
index 4a161a17a1..7292f3a38f 100644
--- a/qobject/json-streamer.c
+++ b/qobject/json-streamer.c
@@ -12,6 +12,7 @@
*/
#include "qapi/qmp/qlist.h"
+#include "qapi/qmp/qstring.h"
#include "qapi/qmp/qint.h"
#include "qapi/qmp/qdict.h"
#include "qemu-common.h"
@@ -21,7 +22,8 @@
#define MAX_TOKEN_SIZE (64ULL << 20)
#define MAX_NESTING (1ULL << 10)
-static void json_message_process_token(JSONLexer *lexer, QString *token, JSONTokenType type, int x, int y)
+static void json_message_process_token(JSONLexer *lexer, GString *input,
+ JSONTokenType type, int x, int y)
{
JSONMessageParser *parser = container_of(lexer, JSONMessageParser, lexer);
QDict *dict;
@@ -45,12 +47,11 @@ static void json_message_process_token(JSONLexer *lexer, QString *token, JSONTok
dict = qdict_new();
qdict_put(dict, "type", qint_from_int(type));
- QINCREF(token);
- qdict_put(dict, "token", token);
+ qdict_put(dict, "token", qstring_from_str(input->str));
qdict_put(dict, "x", qint_from_int(x));
qdict_put(dict, "y", qint_from_int(y));
- parser->token_size += token->length;
+ parser->token_size += input->len;
qlist_append(parser->tokens, dict);