Received: from eggs.gnu.org ([2001:4830:134:3::10]:38459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyORe-0000Vb-S4 for qemu-devel@nongnu.org; Tue, 09 Dec 2014 12:19:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XyORV-0006jK-ML for qemu-devel@nongnu.org; Tue, 09 Dec 2014 12:19:30 -0500 Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]:42697) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyORV-0006jE-GL for qemu-devel@nongnu.org; Tue, 09 Dec 2014 12:19:21 -0500 Received: by mail-wi0-f182.google.com with SMTP id h11so2479645wiw.9 for ; Tue, 09 Dec 2014 09:19:21 -0800 (PST) Date: Tue, 9 Dec 2014 17:19:16 +0000 From: Stefan Hajnoczi Message-ID: <20141209171916.GF27053@stefanha-thinkpad.redhat.com> References: <1417465816-19345-1-git-send-email-jsnow@redhat.com> <1417465816-19345-5-git-send-email-jsnow@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qp4W5+cUSnZs0RIF" Content-Disposition: inline In-Reply-To: <1417465816-19345-5-git-send-email-jsnow@redhat.com> Subject: Re: [Qemu-devel] [PATCH v9 04/10] hbitmap: Add hbitmap_copy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow Cc: kwolf@redhat.com, Fam Zheng , armbru@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, vsementsov@parallels.com, stefanha@redhat.com, pbonzini@redhat.com --qp4W5+cUSnZs0RIF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Dec 01, 2014 at 03:30:10PM -0500, John Snow wrote: > +HBitmap *hbitmap_copy(const HBitmap *bitmap) > +{ > + int i; > + uint64_t size; > + HBitmap *hb = g_memdup(bitmap, sizeof(HBitmap)); > + > + size = bitmap->size; > + for (i = HBITMAP_LEVELS - 1; i >= 0; i--) { > + size = MAX((size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1); > + hb->levels[i] = g_memdup(bitmap->levels[i], > + size * sizeof(unsigned long)); > + } > + > + return hb; > +} It would be handy to put a comment in struct HBitmap warning people that hbitmap_copy() must be kept in sync when new pointer fields are added. --qp4W5+cUSnZs0RIF Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUhy8UAAoJEJykq7OBq3PIu9cH/1aWvGWdAJlZKdzs5WtovcW1 gpx3JbVEnlhgnewCNuCZCHYV26TSOI4oye5AWJZWdHgWyAY7QGnRSRxabipCf6T7 /1SlCLNPVqN0PPvLvPs4HTCHWQDvYn5gKp4jjcMuhoaK52JX1J+F0yOnXk3I88Bu 8HX0MZtR9sU6LeGsbF/7Q2Rn0xB2FVl1RZFln4m/AY6DFp2FfAuXs6MbSHZ7P8/I DiyNonjEAuIUBhAdK4CchF5XyKjqZ5Btx1E+h/4oUooVC0/rtJhhPabiNFQ2mHUp Iama3QS7WokDxY8QFBOZyoiUndedOb4CGfOE3eU83gtQrtdwVKTJW/BQMT5q4NE= =C4tW -----END PGP SIGNATURE----- --qp4W5+cUSnZs0RIF--