diff options
author | NODA, Kai <nodakai@gmail.com> | 2012-04-21 22:41:27 +0900 |
---|---|---|
committer | Luiz Capitulino <lcapitulino@redhat.com> | 2012-04-23 13:03:45 -0300 |
commit | 57a33d89672d7c6b1864185652b7cae0747f8323 (patch) | |
tree | f67dd7082660465bf9d5f80ca41ce996d59c441c /qapi | |
parent | db58f9c0605fa151b8c4d691aa9ff4c6cf0de62e (diff) |
qapi: g_hash_table_find() instead of GHashTableIter.
GHashTableIter was first introduced in glib 2.16.
This patch removes it in favor of older g_hash_table_find()
for better compatibility with RHEL5.
Signed-off-by: NODA, Kai <nodakai@gmail.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'qapi')
-rw-r--r-- | qapi/qmp-input-visitor.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c index 74386b9b1b..4cdc47dab5 100644 --- a/qapi/qmp-input-visitor.c +++ b/qapi/qmp-input-visitor.c @@ -87,20 +87,29 @@ static void qmp_input_push(QmpInputVisitor *qiv, QObject *obj, Error **errp) qiv->nb_stack++; } +/** Only for qmp_input_pop. */ +static gboolean always_true(gpointer key, gpointer val, gpointer user_pkey) +{ + *(const char **)user_pkey = (const char *)key; + return TRUE; +} + static void qmp_input_pop(QmpInputVisitor *qiv, Error **errp) { - GHashTableIter iter; - gpointer key; + assert(qiv->nb_stack > 0); - if (qiv->strict && qiv->stack[qiv->nb_stack - 1].h) { - g_hash_table_iter_init(&iter, qiv->stack[qiv->nb_stack - 1].h); - if (g_hash_table_iter_next(&iter, &key, NULL)) { - error_set(errp, QERR_QMP_EXTRA_MEMBER, (char *) key); + if (qiv->strict) { + GHashTable * const top_ht = qiv->stack[qiv->nb_stack - 1].h; + if (top_ht) { + if (g_hash_table_size(top_ht)) { + const char *key; + g_hash_table_find(top_ht, always_true, &key); + error_set(errp, QERR_QMP_EXTRA_MEMBER, key); + } + g_hash_table_unref(top_ht); } - g_hash_table_unref(qiv->stack[qiv->nb_stack - 1].h); } - assert(qiv->nb_stack > 0); qiv->nb_stack--; } |