From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bB2s6-0003Bh-LT for qemu-devel@nongnu.org; Thu, 09 Jun 2016 12:31:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bB2s4-0005SZ-Gz for qemu-devel@nongnu.org; Thu, 09 Jun 2016 12:31:53 -0400 References: <1463632874-28559-1-git-send-email-eblake@redhat.com> <1463632874-28559-22-git-send-email-eblake@redhat.com> <87y46nd3b0.fsf@dusky.pond.sub.org> From: Eric Blake Message-ID: <575999EE.1000806@redhat.com> Date: Thu, 9 Jun 2016 10:31:42 -0600 MIME-Version: 1.0 In-Reply-To: <87y46nd3b0.fsf@dusky.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="r2pGeXFbwSCuPSGwRpTQX9gE8xfBuLI52" Subject: Re: [Qemu-devel] [PATCH v4 21/28] qstring: Add qstring_wrap_str() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, Kevin Wolf , "open list:Block layer core" , Chrysostomos Nanakos , Jeff Cody , Luiz Capitulino , Max Reitz This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --r2pGeXFbwSCuPSGwRpTQX9gE8xfBuLI52 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/02/2016 09:21 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> Several spots in the code malloc a string, then wrap it in a >> QString, which has to duplicate the input. Adding a new >> constructor with transfer semantics makes this pattern more >> efficient, comparable to the just-added transfer semantics to >> go from QString back to raw string. Use the new >> qstring_wrap_str() where it makes sense. >> >> The new test still passes under valgrind. >> >> Signed-off-by: Eric Blake >> >> +++ b/qobject/qstring.c >> @@ -66,6 +66,31 @@ QString *qstring_from_str(const char *str) >> return qstring_from_substr(str, 0, strlen(str) - 1); >> } >> >> +/** >> + * qstring_wrap_str(): Create a new QString around a malloc'd C strin= g >> + * >> + * Returns a strong reference, and caller must not use @str any more.= >> + * @str may be NULL, in which case the QString will be "". >=20 > I'm not fond of conflating null pointers and "" (see also the trouble > with visit_type_str()). For what it's worth, qstring_from_str(NULL) > crashes. Can we reject null? Probably. I'll add an assert, and update the interface to match if things still pass with my usage. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --r2pGeXFbwSCuPSGwRpTQX9gE8xfBuLI52 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXWZnuAAoJEKeha0olJ0Nq1M4H/ixgBaVsJyMSyrs6sRxco0ET 5aY1aDZ66FhR66QO5DOXJYBnGhg9zSYC2z4Cs8SSxUp4+utplAaDNQF5WNvdO9Mr EkNoZvKQC182Fy/Era+nsxmnM82KqfFRMLcoUoeRbffb5kEzXdkEX9UVNrfugMIV xjXJIwUkCjCDveJVOKSZJa73FpQo9kZGcaBPVAN/t153Kv5yzJzF6qQCWYrV2xpV MkpQjehMKvQHXrYWeUVvAQZaepfUtw4qaCCeVc+1/HU0mmmhg0zJKVepOnFxCE7j SSBzB2+7J4C4zwSd3JmJQVb5HkBRv8FhiavEqw4P7CcQAV2LM7B3fUgBzQmHqNA= =EKGI -----END PGP SIGNATURE----- --r2pGeXFbwSCuPSGwRpTQX9gE8xfBuLI52--