]> git.ipfire.org Git - thirdparty/qemu.git/commit
bitmap: Use g_try_new0/g_new0/g_renew
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 2 May 2024 14:18:18 +0000 (16:18 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 3 May 2024 13:47:48 +0000 (15:47 +0200)
commit5e9efe31f1de05c8c65a7383fcbf211ebded6a22
treef06288723865876151c09259794d75d0080d37a8
parentb10b2481738304db13d28252e86c10555121a5b3
bitmap: Use g_try_new0/g_new0/g_renew

Avoids an explicit use of sizeof().  The GLib allocation macros
ensure that the multiplication by the size of the element
uses the right type and does not overflow.

While at it, change bitmap_new() to use g_new0 directly.  Its current
impl of calling bitmap_try_new() followed by a plain abort() has
worse diagnostics than g_new0, which uses g_error to report the actual
allocation size that failed.

Cc: qemu-trivial@nongnu.org
Cc: Roman Kiryanov <rkir@google.com>
Reviewed-by: Daniel Berrange <berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/qemu/bitmap.h