From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=37693 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OUPLF-0006Yh-5S for qemu-devel@nongnu.org; Thu, 01 Jul 2010 15:22:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OUPL5-0007Ly-HQ for qemu-devel@nongnu.org; Thu, 01 Jul 2010 15:22:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20670) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OUPL5-0007Lk-AN for qemu-devel@nongnu.org; Thu, 01 Jul 2010 15:22:23 -0400 From: Luiz Capitulino Date: Thu, 1 Jul 2010 16:21:39 -0300 Message-Id: <1278012111-26227-12-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1278012111-26227-1-git-send-email-lcapitulino@redhat.com> References: <1278012111-26227-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PATCH 11/23] QDict: Introduce functions to retrieve QDictEntry values List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: aliguori@us.ibm.com Cc: qemu-devel@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); -- 1.7.2.rc0