mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
virBitmapNewCopy: Reimplement bitmap copying to prevent failure
virBitmapCopy has a failure condition, which is impossible to meet when creating a new copy. Copy the contents directly to make it obvious that virBitmapNewCopy can't fail. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
cb6fdb0125
commit
6b18cafb1d
@ -655,20 +655,14 @@ virBitmapParseUnlimited(const char *str)
|
|||||||
* virBitmapNewCopy:
|
* virBitmapNewCopy:
|
||||||
* @src: the source bitmap.
|
* @src: the source bitmap.
|
||||||
*
|
*
|
||||||
* Makes a copy of bitmap @src.
|
* Returns a copy of bitmap @src.
|
||||||
*
|
|
||||||
* returns the copied bitmap on success, or NULL otherwise. Caller
|
|
||||||
* should call virBitmapFree to free the returned bitmap.
|
|
||||||
*/
|
*/
|
||||||
virBitmapPtr
|
virBitmapPtr
|
||||||
virBitmapNewCopy(virBitmapPtr src)
|
virBitmapNewCopy(virBitmapPtr src)
|
||||||
{
|
{
|
||||||
virBitmapPtr dst = virBitmapNew(src->nbits);
|
virBitmapPtr dst = virBitmapNew(src->nbits);
|
||||||
|
|
||||||
if (virBitmapCopy(dst, src) != 0) {
|
memcpy(dst->map, src->map, src->map_len * sizeof(src->map[0]));
|
||||||
virBitmapFree(dst);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user