[PATCH 3/3] clients: Check zalloc return for out of memory situation

Bryce W. Harrington b.harrington at samsung.com
Mon Apr 28 11:43:43 PDT 2014


On Thu, Apr 24, 2014 at 04:26:20PM +0300, Pekka Paalanen wrote:
> On Mon, 21 Apr 2014 23:51:03 +0000
> "Bryce W. Harrington" <b.harrington at samsung.com> wrote:
> >  	terminal = xzalloc(sizeof *terminal);
> > +	if (terminal == NULL)
> > +		return NULL;
> 
> No need to check 'terminal', xzalloc() will exit() if it ever goes NULL.
> 
> I'd be fine with converting all the *allocs to the x*alloc which checks
> for NULL and exits. All programs using window.h can do that.

Kristian writes:
> In the clients we use the x*alloc functions which abort on allocation failure.


Okay, I'll respin the patch to use the x*alloc functions for terminal.c.

I notice that other clients are using the regular alloc functions,
would you be open to a review of these and possibly a patch to convert
them to x*alloc where appropriate?

$ grep -I alloc * --exclude window.* | egrep -v "(x.alloc|allocat|zalloc|xrealloc)" | wc -l
46

Bryce


More information about the wayland-devel mailing list