From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abshc-0003k4-Pm for qemu-devel@nongnu.org; Fri, 04 Mar 2016 11:35:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1abshX-00039e-S3 for qemu-devel@nongnu.org; Fri, 04 Mar 2016 11:35:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38964) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abshX-00039U-Ls for qemu-devel@nongnu.org; Fri, 04 Mar 2016 11:35:39 -0500 References: <1457103235-3341-1-git-send-email-sarahjmi07@gmail.com> <56D9AD78.8070802@redhat.com> From: Eric Blake Message-ID: <56D9B958.4080605@redhat.com> Date: Fri, 4 Mar 2016 09:35:36 -0700 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="4cHVSd6fPbaHQaLfmAfQNletxl3F3jTg4" Subject: Re: [Qemu-devel] [PATCH][Outreachy] Signed-off-by: Sarah Khan List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Sarah Khan , QEMU Developers This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --4cHVSd6fPbaHQaLfmAfQNletxl3F3jTg4 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 03/04/2016 09:06 AM, Peter Maydell wrote: >>> +++ b/thunk.c >>> @@ -88,7 +88,7 @@ void thunk_register_struct(int id, const char *name= , const argtype *types) >>> for(i =3D 0;i < 2; i++) { >>> offset =3D 0; >>> max_align =3D 1; >>> - se->field_offsets[i] =3D malloc(nb_fields * sizeof(int)); >>> + se->field_offsets[i] =3D g_malloc(nb_fields * sizeof(int)); >>> type_ptr =3D se->field_types; >>> for(j =3D 0;j < nb_fields; j++) { >>> size =3D thunk_type_size(type_ptr, i); >> >> Where is the corresponding free()? g_malloc() must be paired with >> g_free(), so you need to convert both places at once. >=20 > There is no corresponding free(). thunk_register_struct() is called > only at startup from the linux-user code in order to populate the > struct_entries array; this data structure then remains live for > the entire lifetime of the program and is automatically freed when > QEMU exits. Fair enough. However, g_new(int, nb_fields) is probably a bit nicer than g_malloc() (in that it would detect multiplication overflow if nb_fields were ever oversized). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --4cHVSd6fPbaHQaLfmAfQNletxl3F3jTg4 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/ iQEcBAEBCAAGBQJW2blZAAoJEKeha0olJ0Nqs6MH/jxM+3QN0SUdlzSt3lbGMGaR 3lmSJ9JEasRX7xaUvZwxXG4oBb4QJos3edw7G1FvdiIo+bZzXCtGSbas28TJcGQl uXfqgV5BUJV8JeAGOylW0sI1LjYgZFXx7Au/yhZs6Q7oJ88tIUp2403zPDGZRH2O SfCQXEFyON91SUOoHA6fw8sOHr4RJX5hG5OP3sqqvc8JRQA51OP2M8YdGboCAF9u pHVms9t1riwoMTrMF6TlSlM/nss/WypDCeiI1Owtcr1X08SCjWnN8XcSIaYIxXxU i69RBM/3qcnp8EVLYeTHBxcfi2VIBorxN/uoawd7g4FgiX5RChDWJ81Z1Exx0mo= =qj0a -----END PGP SIGNATURE----- --4cHVSd6fPbaHQaLfmAfQNletxl3F3jTg4--