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

Pekka Paalanen ppaalanen at gmail.com
Tue Apr 29 00:32:36 PDT 2014


On Mon, 28 Apr 2014 18:43:43 +0000
"Bryce W. Harrington" <b.harrington at samsung.com> wrote:

> 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

Hi,

now that we already have the x*alloc functions and they are obviously
accepted in the client coding style, sure, why not.

I think if clients use zalloc, that could be converted to xzalloc, too.


Thanks,
pq


More information about the wayland-devel mailing list