[PATCH weston] tests: Convert 'xalloc's to 'zalloc's

Bryce Harrington bryce at osg.samsung.com
Tue Sep 8 22:39:44 PDT 2015


On Mon, Sep 07, 2015 at 04:46:40PM +0300, Pekka Paalanen wrote:
> On Fri,  4 Sep 2015 23:47:09 +0530
> Seedo Eldho Paul <seedoeldhopaul at gmail.com> wrote:
> 
> > xalloc terminates the program abruptly if the requested amount of
> > memory couldn't be allocated. To insure that the errors are handled
> > cleanly, use zalloc instead.
> > 
> > Signed-off-by: Seedo Eldho Paul <seedoeldhopaul at gmail.com>

LGTM too,
Reviewed-by: Bryce Harrington <bryce at osg.samsung.com>

> > ---
> >  tests/internal-screenshot-test.c | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> > 
> > diff --git a/tests/internal-screenshot-test.c b/tests/internal-screenshot-test.c
> > index e72a695..6b26e1a 100644
> > --- a/tests/internal-screenshot-test.c
> > +++ b/tests/internal-screenshot-test.c
> > @@ -30,6 +30,7 @@
> >  #include <string.h> /* memcpy */
> >  #include <cairo.h>
> >  
> > +#include "zalloc.h"
> >  #include "weston-test-client-helper.h"
> >  
> >  char *server_parameters="--use-pixman --width=320 --height=240";
> > @@ -92,9 +93,9 @@ load_surface_from_png(const char *fname)
> >  	}
> >  
> >  	/* Disguise the cairo surface in a weston test surface */
> > -	reference = xzalloc(sizeof *reference);
> > +	reference = zalloc(sizeof *reference);
> >  	if (reference == NULL) {
> > -		perror("xzalloc reference");
> > +		perror("zalloc reference");
> >  		cairo_surface_destroy(reference_cairo_surface);
> >  		return NULL;
> >  	}
> > @@ -114,9 +115,9 @@ load_surface_from_png(const char *fname)
> >  
> >  	/* Allocate new buffer for our weston reference, and copy the data from
> >  	   the cairo surface so we can destroy it */
> > -	reference->data = xzalloc(source_data_size);
> > +	reference->data = zalloc(source_data_size);
> >  	if (reference->data == NULL) {
> > -		perror("xzalloc reference data");
> > +		perror("zalloc reference data");
> >  		cairo_surface_destroy(reference_cairo_surface);
> >  		free(reference);
> >  		return NULL;
> > @@ -143,7 +144,7 @@ static struct surface*
> >  create_screenshot_surface(struct client *client)
> >  {
> >  	struct surface* screenshot;
> > -	screenshot = xzalloc(sizeof *screenshot);
> > +	screenshot = zalloc(sizeof *screenshot);
> >  	if (screenshot == NULL)
> >  		return NULL;
> >  	screenshot->wl_buffer = create_shm_buffer(client,
> 
> Acked-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> 
> 
> Thanks,
> pq

> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2
> 
> iQIVAwUBVe2VRiNf5bQRqqqnAQi+1w//cqtF3hGVxxvpUHeGkiiwapMV1ZaZ2MjL
> RAAmW0O/ImscUZY/lJBVaFPaU5SY5ev55XIOvGgYZ8NGctcfGV6xKtOvKvVEcRH/
> oYd7gdFudR0FRbkmtkze1v0BST1H8QYWj5ICIG8DgCxMDwQCYpG7ESSLvzZY2bL4
> /gk+DTotnXWBXYc7i3czs4LQMRk8GJpdTP/mOTZwdP+wUJ1ihewKV9+wQ9eU4qu4
> I9eva+c1oY7sc11I+frr3LAmZwwUpZIvcuPEsPhoamTY9rhfSnhyJkuf4nfcFFMh
> gBwryb+/n3XSbffS9d+ZTxnGoADshbgmk09dtHEtOIZ1fmAjTtvPH5CNJtwZSMrd
> K34Pc5v15Rr09UDBA9alyzQR+c75cXgU3A1imrq7J9tBiXxNEEK9uf6vQyGDGDkd
> HgC3gwK1quzLWpi7gLRALqxB4Bj5FpTFEEr9Q3UJFx3oDizxeI+lEF0ff/TZ1TN6
> tT7hxj/1JqCET3xvPvbbF9YIGc/PnrOITZPQ/tPkarMY/oEXNQ/UEWFobZdXGV0N
> h8Yl1YafdefQ89JbUTr92y3qdSiJ3E55OHJE544hBnMJ7sfjACHSY+Otcro+3hyz
> O5XC0AOSMiUl2uA16JnSqd6ujK+nqDoXQidT3nH/AnTyxMkgG1qb61+u6a0rGF+4
> C3tc7zrA7Eo=
> =UuMS
> -----END PGP SIGNATURE-----



More information about the wayland-devel mailing list