]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Add a virBitmapCopy API
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 6 Sep 2012 15:09:32 +0000 (16:09 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 13 Sep 2012 10:44:01 +0000 (11:44 +0100)
Add an API allowing flags from one virBitmapPtr to be copied
into another instance.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/libvirt_private.syms
src/util/bitmap.c
src/util/bitmap.h

index 0494e1f525bb4b203f2625e6e5b98023f1364716..8dfb4cee99ba16ae28f1ad7dc2b0e3a67a425866 100644 (file)
@@ -8,6 +8,7 @@
 # bitmap.h
 virBitmapAlloc;
 virBitmapClearBit;
+virBitmapCopy;
 virBitmapFree;
 virBitmapGetBit;
 virBitmapSetBit;
index 53a8a3875c6cc88471aa01e85284a54de1595472..cd52802facc290e2bdd908e9d2314b057e375690 100644 (file)
@@ -93,6 +93,25 @@ void virBitmapFree(virBitmapPtr bitmap)
     }
 }
 
+
+int virBitmapCopy(virBitmapPtr dst, virBitmapPtr src)
+{
+    size_t sz;
+
+    if (dst->size != src->size) {
+        errno = EINVAL;
+        return -1;
+    }
+
+    sz = (src->size + VIR_BITMAP_BITS_PER_UNIT - 1) /
+        VIR_BITMAP_BITS_PER_UNIT;
+
+    memcpy(dst->map, src->map, sz * sizeof(src->map[0]));
+
+    return 0;
+}
+
+
 /**
  * virBitmapSetBit:
  * @bitmap: Pointer to bitmap
index c3e6222b745d42021d14f707dcb19ec43219c3de..1d8750e8b094bd468bc552670c9f940254e8b681 100644 (file)
@@ -41,6 +41,12 @@ virBitmapPtr virBitmapAlloc(size_t size) ATTRIBUTE_RETURN_CHECK;
  */
 void virBitmapFree(virBitmapPtr bitmap);
 
+/*
+ * Copy all bits from @src to @dst. The bitmap sizes
+ * must be the same
+ */
+int virBitmapCopy(virBitmapPtr dst, virBitmapPtr src);
+
 /*
  * Set bit position @b in @bitmap
  */