From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:60368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxiEh-0006Eq-4P for qemu-devel@nongnu.org; Wed, 15 Feb 2012 12:01:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RxiEZ-00020V-PR for qemu-devel@nongnu.org; Wed, 15 Feb 2012 12:01:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43844) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxiEZ-0001zn-GG for qemu-devel@nongnu.org; Wed, 15 Feb 2012 12:01:35 -0500 Date: Wed, 15 Feb 2012 15:01:27 -0200 From: Luiz Capitulino Message-ID: <20120215150127.411e4e66@doriath.home> In-Reply-To: <8739aci6nr.fsf@elfo.elfo> References: <1328902266-25308-1-git-send-email-lcapitulino@redhat.com> <1328902266-25308-4-git-send-email-lcapitulino@redhat.com> <8739aci6nr.fsf@elfo.elfo> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 3/6] QDict: Introduce qdict_copy() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: quintela@redhat.com Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org On Wed, 15 Feb 2012 14:10:32 +0100 Juan Quintela wrote: > 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? I think this only matters for threaded applications. QDicts are not thread safe, so this is not an issue but I'll drop this patch anyway (in favor of increfing the error object).