From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Me3DA-0001HW-WA for qemu-devel@nongnu.org; Thu, 20 Aug 2009 04:41:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Me3D6-0001FX-BG for qemu-devel@nongnu.org; Thu, 20 Aug 2009 04:41:32 -0400 Received: from [199.232.76.173] (port=52881 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Me3D6-0001FS-6Y for qemu-devel@nongnu.org; Thu, 20 Aug 2009 04:41:28 -0400 Received: from ey-out-1920.google.com ([74.125.78.149]:19875) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Me3D5-00027Z-Sz for qemu-devel@nongnu.org; Thu, 20 Aug 2009 04:41:28 -0400 Received: by ey-out-1920.google.com with SMTP id 5so965826eyb.4 for ; Thu, 20 Aug 2009 01:41:27 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4A8D0C34.2000600@gnu.org> Date: Thu, 20 Aug 2009 10:41:24 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1250723280-3509-1-git-send-email-lcapitulino@redhat.com> <1250723280-3509-4-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1250723280-3509-4-git-send-email-lcapitulino@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 03/29] Introduce QString List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org, avi@redhat.com 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