From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:48177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rxed9-0004sd-39 for qemu-devel@nongnu.org; Wed, 15 Feb 2012 08:10:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rxed2-0006gP-Cy for qemu-devel@nongnu.org; Wed, 15 Feb 2012 08:10:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:24259) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rxed1-0006fx-W4 for qemu-devel@nongnu.org; Wed, 15 Feb 2012 08:10:36 -0500 From: Juan Quintela In-Reply-To: <1328902266-25308-4-git-send-email-lcapitulino@redhat.com> (Luiz Capitulino's message of "Fri, 10 Feb 2012 17:31:03 -0200") References: <1328902266-25308-1-git-send-email-lcapitulino@redhat.com> <1328902266-25308-4-git-send-email-lcapitulino@redhat.com> Date: Wed, 15 Feb 2012 14:10:32 +0100 Message-ID: <8739aci6nr.fsf@elfo.elfo> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 3/6] QDict: Introduce qdict_copy() Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org Luiz Capitulino wrote: > Signed-off-by: Luiz Capitulino > /** > + * qdict_copy(): Build a new dictionary from an existing one. > + */ > +QDict *qdict_copy(const QDict *from) > +{ > + const QDictEntry *ent; > + QDict *new; > + > + new = qdict_new(); > + > + for (ent = qdict_first(from); ent; ent = qdict_next(from, ent)) { > + qdict_put_obj(new, qdict_entry_key(ent), qdict_entry_value(ent)); > + qobject_incref(qdict_entry_value(ent)); > + } Without having any clue about how qobject refcounting works, it looks suspicious that we first insert an object in a dict, and increase the ref counter after. Shouldn't we do it the other way around? Later, Juan.