diff mbox

[16/38] bitmap: Add bitmap_zero_extend operation

Message ID 1387293974-24718-17-git-send-email-quintela@redhat.com
State New
Headers show

Commit Message

Juan Quintela Dec. 17, 2013, 3:25 p.m. UTC
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 include/qemu/bitmap.h | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Orit Wasserman Dec. 18, 2013, 10:18 a.m. UTC | #1
On 12/17/2013 05:25 PM, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
>   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 */
>

Reviewed-by: Orit Wasserman <owasserm@redhat.com>
diff mbox

Patch

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 */