From patchwork Tue Jun 22 17:40:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 56543 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 CBD0AB6F0C for ; Wed, 23 Jun 2010 03:42:57 +1000 (EST) Received: from localhost ([127.0.0.1]:45186 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OR7Us-0004Pd-3m for incoming@patchwork.ozlabs.org; Tue, 22 Jun 2010 13:42:54 -0400 Received: from [140.186.70.92] (port=55501 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OR7TE-0004NF-0q for qemu-devel@nongnu.org; Tue, 22 Jun 2010 13:41:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OR7TB-0000aL-OB for qemu-devel@nongnu.org; Tue, 22 Jun 2010 13:41:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58823) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OR7TB-0000aF-Dj for qemu-devel@nongnu.org; Tue, 22 Jun 2010 13:41:09 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5MHf8es030017 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 22 Jun 2010 13:41:08 -0400 Received: from localhost (vpn-10-15.rdu.redhat.com [10.11.10.15]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5MHf72F026789; Tue, 22 Jun 2010 13:41:07 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Tue, 22 Jun 2010 14:40:41 -0300 Message-Id: <1277228451-7741-4-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1277228451-7741-1-git-send-email-lcapitulino@redhat.com> References: <1277228451-7741-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: armbru@redhat.com Subject: [Qemu-devel] [PATCH 03/13] 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);