|
From: | Avi Kivity |
Subject: | [Qemu-devel] Re: [PATCH 01/25] Introduce QEMU dictionary data type |
Date: | Wed, 29 Jul 2009 12:49:19 +0300 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Lightning/1.0pre Thunderbird/3.0b2 |
On 07/29/2009 12:47 PM, Avi Kivity wrote:
+ +struct qemu_dict *qemu_dict_create(void);+void qemu_dict_add(struct qemu_dict *qdict, const char *key, void *value);+void *qemu_dict_get(const struct qemu_dict *qdict, const char *key); +int qemu_dict_exists(const struct qemu_dict *qdict, const char *key); +void *qemu_dict_del(struct qemu_dict *qdict, const char *key); +void qemu_dict_destroy(struct qemu_dict *qdict); +void qemu_dict_walk(const struct qemu_dict *qdict, + void (*walkf)(const char *key, void *value)); +I'm worried about all those void *s as they move responsibility for type safety and lifecycle management to the user. I'd much rather see a QObject (or Object) with the following methods:clone() - deep copy an object; dicts will store copies so we'll avoid those leaks or a dictionary member modified after it was storeddestroy() type() - return the typeas_dict(), as_string(), as_int() - convert to a subclass so its methods can be usedConsider an operation such as printing out the dictionary, you have to know the types of the values.
Note, if we decide we want this it could be introduced later to avoid excessive churn on this patchset.
-- error compiling committee.c: too many arguments to function
[Prev in Thread] | Current Thread | [Next in Thread] |