mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +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:
|
||||
* @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.
|
||||
* Returns a copy of bitmap @src.
|
||||
*/
|
||||
virBitmapPtr
|
||||
virBitmapNewCopy(virBitmapPtr src)
|
||||
{
|
||||
virBitmapPtr dst = virBitmapNew(src->nbits);
|
||||
|
||||
if (virBitmapCopy(dst, src) != 0) {
|
||||
virBitmapFree(dst);
|
||||
return NULL;
|
||||
}
|
||||
memcpy(dst->map, src->map, src->map_len * sizeof(src->map[0]));
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user