Re: [ocaml PATCH] Use caml_raise_out_of_memory() where needed.

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

 



On Thu, Sep 05, 2019 at 02:54:53PM +0200, Pino Toscano wrote:
> Raise the proper exception on malloc failures.
> 
> Signed-off-by: Pino Toscano <ptoscano@xxxxxxxxxx>
> ---
>  libvirt/libvirt_c_oneoffs.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libvirt/libvirt_c_oneoffs.c b/libvirt/libvirt_c_oneoffs.c
> index e23c0db..40384e8 100644
> --- a/libvirt/libvirt_c_oneoffs.c
> +++ b/libvirt/libvirt_c_oneoffs.c
> @@ -749,7 +749,7 @@ ocaml_libvirt_domain_get_cpu_stats (value domv)
>    CHECK_ERROR (nparams < 0, "virDomainGetCPUStats");
>  
>    if ((params = malloc(sizeof(*params) * nparams * 128)) == NULL)
> -    caml_failwith ("virDomainGetCPUStats: malloc");
> +    caml_raise_out_of_memory ();
>  
>    cpustats = caml_alloc (nr_pcpus, 0); /* cpustats: array of params(list of typed_param) */
>    cpu = 0;
> @@ -1461,7 +1461,7 @@ ocaml_libvirt_event_add_timeout (value connv, value ms, value callback_id)
>    /* Store the int64 callback_id as the opaque data so the OCaml
>       callback can demultiplex to the correct OCaml handler. */
>    if ((opaque = malloc(sizeof(long))) == NULL)
> -    caml_failwith ("virEventAddTimeout: malloc");
> +    caml_raise_out_of_memory ();
>    *((long*)opaque) = Int64_val(callback_id);
>    NONBLOCKING(r = virEventAddTimeout(Int_val(ms), cb, opaque, freecb));
>    CHECK_ERROR(r == -1, "virEventAddTimeout");
> @@ -1551,7 +1551,7 @@ ocaml_libvirt_connect_domain_event_register_any(value connv, value domv, value c
>    /* Store the int64 callback_id as the opaque data so the OCaml
>       callback can demultiplex to the correct OCaml handler. */
>    if ((opaque = malloc(sizeof(long))) == NULL)
> -    caml_failwith ("virConnectDomainEventRegisterAny: malloc");
> +    caml_raise_out_of_memory ();
>    *((long*)opaque) = Int64_val(callback_id);
>    NONBLOCKING(r = virConnectDomainEventRegisterAny(conn, dom, eventID, cb, opaque, freecb));
>    CHECK_ERROR(r == -1, "virConnectDomainEventRegisterAny");

ACK.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v

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

  Powered by Linux