Re: [PATCH v3 2/9] New functions for virBitmap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 13, 2012 at 02:03:20PM +0800, Hu Tao wrote:
> In many places we store bitmap info in a chunk of data
> (pointed to by a char *), and have redundant codes to
> set/unset bits. This patch extends virBitmap, and convert
> those codes to use virBitmap in subsequent patches.
> ---
>  .gitignore               |    1 +
>  src/libvirt_private.syms |   11 ++
>  src/util/bitmap.c        |  405 +++++++++++++++++++++++++++++++++++++++++++++-
>  src/util/bitmap.h        |   34 ++++
>  tests/Makefile.am        |    7 +-
>  tests/virbitmaptest.c    |  362 +++++++++++++++++++++++++++++++++++++++++
>  6 files changed, 818 insertions(+), 2 deletions(-)
>  create mode 100644 tests/virbitmaptest.c
> 
> diff --git a/.gitignore b/.gitignore
> index d998f0e..1ca537e 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -157,6 +157,7 @@
>  /tests/utiltest
>  /tests/viratomictest
>  /tests/virauthconfigtest
> +/tests/virbitmaptest
>  /tests/virbuftest
>  /tests/virdrivermoduletest
>  /tests/virhashtest
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 8dfb4ce..0ad6376 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -7,12 +7,23 @@
>  
>  # bitmap.h
>  virBitmapAlloc;
> +virBitmapAllocFromData;

Hmm, can you rename the existing method 'virBitmapNew' and
then call you addition 'virBitmapNewData'


> +/**
> + * virBitmapCopy:

s/Copy/NewCopy/

> + * @src: the source bitmap.
> + *
> + * Makes a copy of bitmap @src.
> + *
> + * returns the copied bitmap on success, or NULL otherwise. Caller
> + * should call virBitmapFree to free the returned bitmap.
> + */
> +virBitmapPtr virBitmapNewCopy(virBitmapPtr src)
> +{
> +    virBitmapPtr dst;
> +
> +    if ((dst = virBitmapAlloc(src->max_bit)) == NULL)
> +        return NULL;
> +
> +    if (virBitmapCopy(dst, src) != 0) {
> +        virBitmapFree(dst);
> +        return NULL;
> +    }
> +
> +    return dst;
> +}
> +
> +/**
> + * virBitmapAllocFromData:
> + * @data: the data
> + * @len: length of @data in bytes
> + *
> + * Allocate a bitmap from a chunk of data containing bits
> + * information
> + *
> + * Returns a pointer to the allocated bitmap or NULL if
> + * memory cannot be allocated.
> + */
> +virBitmapPtr virBitmapAllocFromData(void *data, int len)

s/AllocFromData/NewData/

> +{
> +    virBitmapPtr bitmap;
> +    int i;
> +
> +    bitmap = virBitmapAlloc(len * CHAR_BIT);
> +    if (!bitmap)
> +        return NULL;
> +
> +    memcpy(bitmap->map, data, len);
> +    for (i = 0; i < bitmap->map_len; i++)
> +        bitmap->map[i] = le64toh(bitmap->map[i]);
> +
> +    return bitmap;
> +}


ACK if those few renames are made


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]