From patchwork Thu Jun 24 21:33:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 56864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3498EB6F29 for ; Fri, 25 Jun 2010 08:17:47 +1000 (EST) Received: from localhost ([127.0.0.1]:57437 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ORuGy-00061X-3c for incoming@patchwork.ozlabs.org; Thu, 24 Jun 2010 17:47:48 -0400 Received: from [140.186.70.92] (port=51694 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ORu3a-0000eW-1t for qemu-devel@nongnu.org; Thu, 24 Jun 2010 17:33:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ORu3Y-0001aU-Qz for qemu-devel@nongnu.org; Thu, 24 Jun 2010 17:33:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58816) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ORu3Y-0001aF-KH for qemu-devel@nongnu.org; Thu, 24 Jun 2010 17:33:56 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5OLXtg6009333 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 24 Jun 2010 17:33:55 -0400 Received: from localhost (vpn-9-104.rdu.redhat.com [10.11.9.104]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5OLXsw9004778; Thu, 24 Jun 2010 17:33:55 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 24 Jun 2010 18:33:29 -0300 Message-Id: <1277415220-17810-4-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1277415220-17810-1-git-send-email-lcapitulino@redhat.com> References: <1277415220-17810-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: armbru@redhat.com Subject: [Qemu-devel] [PATCH 03/14] QDict: Introduce functions to retrieve QDictEntry values X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Next commit will introduce a new QDict iteration API which returns QDictEntry entries, but we don't want users to directly access its members since QDictEntry should be private to QDict. In the near future this kind of data type will be turned into a forward reference. Signed-off-by: Luiz Capitulino --- qdict.c | 21 +++++++++++++++++++++ qdict.h | 2 ++ 2 files changed, 23 insertions(+), 0 deletions(-) diff --git a/qdict.c b/qdict.c index 71be2eb..c467763 100644 --- a/qdict.c +++ b/qdict.c @@ -83,6 +83,27 @@ static QDictEntry *alloc_entry(const char *key, QObject *value) } /** + * qdict_entry_value(): Return qdict entry value + * + * Return weak reference. + */ +QObject *qdict_entry_value(const QDictEntry *entry) +{ + return entry->value; +} + +/** + * qdict_entry_key(): Return qdict entry key + * + * Return a *pointer* to the string, it has to be duplicated before being + * stored. + */ +const char *qdict_entry_key(const QDictEntry *entry) +{ + return entry->key; +} + +/** * qdict_find(): List lookup function */ static QDictEntry *qdict_find(const QDict *qdict, diff --git a/qdict.h b/qdict.h index dcd2b29..0c8de3c 100644 --- a/qdict.h +++ b/qdict.h @@ -34,6 +34,8 @@ typedef struct QDict { /* Object API */ QDict *qdict_new(void); +const char *qdict_entry_key(const QDictEntry *entry); +QObject *qdict_entry_value(const QDictEntry *entry); size_t qdict_size(const QDict *qdict); void qdict_put_obj(QDict *qdict, const char *key, QObject *value); void qdict_del(QDict *qdict, const char *key);