[prev in list] [next in list] [prev in thread] [next in thread] 

List:       libguestfs
Subject:    [Libguestfs] [PATCH nbdkit 7/9] common/bitmap: Add bitmap_clear function.
From:       "Richard W.M. Jones" <rjones () redhat ! com>
Date:       2018-12-28 18:45:58
Message-ID: 20181228184600.30408-8-rjones () redhat ! com
[Download RAW message or body]

Clears the bitmap.
---
 common/bitmap/bitmap.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/common/bitmap/bitmap.h b/common/bitmap/bitmap.h
index 80fd5e4..0da650a 100644
--- a/common/bitmap/bitmap.h
+++ b/common/bitmap/bitmap.h
@@ -42,6 +42,7 @@
 #define NBDKIT_BITMAP_H
 
 #include <stdint.h>
+#include <string.h>
 #include <assert.h>
 
 #include <nbdkit-plugin.h>
@@ -100,6 +101,13 @@ bitmap_free (struct bitmap *bm)
  */
 extern int bitmap_resize (struct bitmap *bm, uint64_t new_size);
 
+/* Clear the bitmap (set everything to zero). */
+static inline void
+bitmap_clear (struct bitmap *bm)
+{
+  memset (bm->bitmap, 0, bm->size);
+}
+
 /* This macro calculates the byte offset in the bitmap and which
  * bit/mask we are addressing within that byte.
  *
-- 
2.19.2

_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic