]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: bitmap: Fix value of 'map_alloc' when shrinking bitmap
authorPeter Krempa <pkrempa@redhat.com>
Mon, 5 Feb 2018 12:36:57 +0000 (13:36 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 5 Feb 2018 15:08:26 +0000 (16:08 +0100)
The virBitmap code uses VIR_RESIZE_N to do quadratic scaling, which
means that along with the number of requested map elements we also need
to keep the number of actually allocated elements for the scaling
algorithm to work properly.

The shrinking code did not fix 'map_alloc' thus virResizeN might
actually not expand the bitmap properly after called on a previously
shrunk bitmap.

src/util/virbitmap.c

index 0973731e3ab064e176c6d5a6a7546302052913c3..d1e5a9d1eacfd298a370dbd9bf8a02d037ee3a90 100644 (file)
@@ -1317,5 +1317,6 @@ virBitmapShrink(virBitmapPtr map,
         return -1;
 
     map->map_len = nl;
+    map->map_alloc = nl;
     return 0;
 }