[PATCH 1/2] clients & tests: Unify multiple definitions of x*alloc and related functions

Bill Spitzak spitzak at gmail.com
Wed Mar 16 18:49:40 UTC 2016


On Tue, Mar 15, 2016 at 3:23 PM, Bryce Harrington <bryce at osg.samsung.com>
wrote:

>
> --- a/clients/ivi-shell-user-interface.c
> +++ b/clients/ivi-shell-user-interface.c
> @@ -40,6 +40,7 @@
>  #include "shared/config-parser.h"
>  #include "shared/helpers.h"
>  #include "shared/os-compatibility.h"
> +#include "shared/xalloc.h"
>  #include "shared/zalloc.h"
>  #include "ivi-application-client-protocol.h"
>  #include "ivi-hmi-controller-client-protocol.h"
> @@ -164,18 +165,6 @@ hmi_homescreen_setting {
>  };
>
>  static void *
> -fail_on_null(void *p, size_t size, char *file, int32_t line)
> -{
> -       if (size && !p) {
> -               fprintf(stderr, "%s(%d) %zd: out of memory\n",
> -                       file, line, size);
> -               exit(EXIT_FAILURE);
> -       }
> -
> -       return p;
> -}
>

The deleted ones in ivi purposely does not fail if size==0. But it appears
they are only called by the MEM_ALLOC macro and that is only called with
sizeof() which is not going to be zero, so this is ok.

>
> -               fail_on_null(window->xdg_surface);
> +               fail_on_null(window->xdg_surface, 1, __FILE__, __LINE__);
>

I think you either want to use sizeof(*window->xdg_surface) or 0 for the
size.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20160316/17e91c59/attachment-0001.html>


More information about the wayland-devel mailing list