[libvirt] [libvirt-glib] Don't mix g_new0 and g_slice_free

Daniel P. Berrange berrange at redhat.com
Fri Jan 6 10:44:45 UTC 2012


On Fri, Jan 06, 2012 at 12:02:36PM +0400, Christophe Fergeau wrote:
> There were 2 places where memory was allocated with g_new0 and was
> later freed with g_slice_free. This commit uses g_slice_new0 instead.
> After this, there are no other occurrences of g_new0 in gobject/ so
> the rest of the codebase should be safe from this issue.
> ---
>  libvirt-gobject/libvirt-gobject-storage-pool.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
> index f46dc32..0ba1768 100644
> --- a/libvirt-gobject/libvirt-gobject-storage-pool.c
> +++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
> @@ -621,7 +621,7 @@ void gvir_storage_pool_build_async (GVirStoragePool *pool,
>      GSimpleAsyncResult *res;
>      StoragePoolBuildData *data;
>  
> -    data = g_new0(StoragePoolBuildData, 1);
> +    data = g_slice_new0(StoragePoolBuildData);
>      data->flags = flags;
>  
>      res = g_simple_async_result_new(G_OBJECT(pool),
> @@ -721,7 +721,7 @@ void gvir_storage_pool_start_async (GVirStoragePool *pool,
>      GSimpleAsyncResult *res;
>      StoragePoolBuildData *data;
>  
> -    data = g_new0(StoragePoolBuildData, 1);
> +    data = g_slice_new0(StoragePoolBuildData);
>      data->flags = flags;
>  
>      res = g_simple_async_result_new(G_OBJECT(pool),

ACK


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 :|




More information about the libvir-list mailing list