From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52603) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQaX9-0005Vf-95 for qemu-devel@nongnu.org; Thu, 20 Mar 2014 06:49:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQaX3-00086O-AO for qemu-devel@nongnu.org; Thu, 20 Mar 2014 06:49:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13682) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQaX2-000869-TG for qemu-devel@nongnu.org; Thu, 20 Mar 2014 06:49:05 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2KAmPn5014795 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 20 Mar 2014 06:48:52 -0400 Date: Thu, 20 Mar 2014 18:47:58 +0800 From: Fam Zheng Message-ID: <20140320104758.GA11666@T430.redhat.com> References: <1394605864-32237-1-git-send-email-famz@redhat.com> <1394605864-32237-6-git-send-email-famz@redhat.com> <532AC178.3030002@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <532AC178.3030002@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 5/9] hbitmap: Add hbitmap_copy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On Thu, 03/20 11:22, Paolo Bonzini wrote: > Il 12/03/2014 07:31, Fam Zheng ha scritto: > >+HBitmap *hbitmap_copy(const HBitmap *bitmap) > >+{ > >+ int i; > >+ HBitmap *hb = g_memdup(bitmap, sizeof(struct HBitmap)); > >+ > >+ for (i = HBITMAP_LEVELS; i-- > 0; ) { > >+ hb->levels[i] = g_memdup(bitmap->levels[i], > >+ bitmap->size * sizeof(unsigned long)); > >+ } > >+ > >+ return hb; > > Not quite... the bitmap->size is in bits, so you need to scale it down by > > size = MAX((size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1); > > before each memdup. > This is fixed in V3 which is posted on the list. Thanks, Fam