From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2lVs-0002NC-1T for qemu-devel@nongnu.org; Mon, 13 Jan 2014 12:41:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2lVl-0006uK-Rw for qemu-devel@nongnu.org; Mon, 13 Jan 2014 12:41:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:8039) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2lVl-0006sJ-Js for qemu-devel@nongnu.org; Mon, 13 Jan 2014 12:41:17 -0500 From: Juan Quintela Date: Mon, 13 Jan 2014 18:40:13 +0100 Message-Id: <1389634834-24181-29-git-send-email-quintela@redhat.com> In-Reply-To: <1389634834-24181-1-git-send-email-quintela@redhat.com> References: <1389634834-24181-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PATCH 28/49] bitmap: Add bitmap_zero_extend operation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: anthony@codemonkey.ws Signed-off-by: Juan Quintela Reviewed-by: Eric Blake Reviewed-by: Orit Wasserman --- include/qemu/bitmap.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h index afdd257..1babd5d 100644 --- a/include/qemu/bitmap.h +++ b/include/qemu/bitmap.h @@ -220,4 +220,13 @@ unsigned long bitmap_find_next_zero_area(unsigned long *map, unsigned long nr, unsigned long align_mask); +static inline unsigned long *bitmap_zero_extend(unsigned long *old, + long old_nbits, long new_nbits) +{ + long new_len = BITS_TO_LONGS(new_nbits) * sizeof(unsigned long); + unsigned long *new = g_realloc(old, new_len); + bitmap_clear(new, old_nbits, new_nbits - old_nbits); + return new; +} + #endif /* BITMAP_H */ -- 1.8.4.2