|
From: | Paolo Bonzini |
Subject: | [Qemu-devel] Re: [PATCH 03/29] Introduce QString |
Date: | Thu, 20 Aug 2009 10:41:24 +0200 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Lightning/1.0pre Thunderbird/3.0b3 |
On 08/20/2009 01:07 AM, Luiz Capitulino wrote:
QString is a high-level data type that can be used to store C strings. The following functions are available: - qstring_from_str() Create a new QString from a C string - qstring_get_str() Return a pointer to the stored string Note that qstring_get_str() is too low-level for a data type like this, but it's interesting for quick read-only accesses.
Same comments as for qint.h. Maybe add qstring_dup_str, doing strdup(qstring_get_str(x))? > + qstring = qemu_malloc(sizeof(*qstring)); > + qstring->string = qemu_strdup(str); > + QOBJECT_INIT(qstring, &qstring_type);Since this is immutable, what about allocating the bytes straight after the QType_HEAD, without going through an additional indirection?
Another useful thingy could be to cache the length, since you have to compute it anyway to allocate the QString. I'm just shooting around ideas, feel free to not implement them if they are not useful in the remainder of the series. :-)
Paolo
[Prev in Thread] | Current Thread | [Next in Thread] |