[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 08/10] qapi: add strict mode to input visitor
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 08/10] qapi: add strict mode to input visitor |
Date: |
Mon, 02 Apr 2012 13:28:53 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 |
Il 02/04/2012 12:34, Laurent Desnogues ha scritto:
>> > static void qmp_input_pop(QmpInputVisitor *qiv, Error **errp)
>> > {
>> > + GHashTableIter iter;
> GHashTableIter is alas not available in the glib (2.12) that
> the distros we use at work run. Is there a workaround for
> this issue?
Yeah, since the hash table is going to be destroyed anyway, and will
always be empty in the common case, you can call
g_hash_table_foreach_remove, and raise an error if it returns > 0
Something like
gboolean hash_table_empty_check(gpointer key, gpointer value,
gpointer user_data)
{
gpointer *p_key = user_data;
if (!*p_key) {
*p_key = key;
}
return true;
}
....
key = NULL;
if (g_hash_table_foreach_remove(qiv->stack[qiv->nb_stack - 1].h,
hash_table_empty_check, &key) {
error_set(errp, QERR_QMP_EXTRA_MEMBER, (char *) key);
}
g_hash_table_unref(qiv->stack[qiv->nb_stack - 1].h);
Can you make a patch?
Paolo