aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2013-10-08 16:12:17 +0200
committerJuan Quintela <quintela@redhat.com>2014-01-13 14:04:54 +0100
commit164590a60fd685399da259ac41b338d9a0b9d6c0 (patch)
tree5afe310f39b0d4978aeb1e2aa6be7f485266a6f1
parente8a97cafc4108fa964807eb9cbce7eda698f99bb (diff)
bitmap: Add bitmap_zero_extend operation
Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Orit Wasserman <owasserm@redhat.com>
-rw-r--r--include/qemu/bitmap.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h
index afdd257d8f..1babd5d812 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 */