<p dir="ltr"><br>
On Sep 5, 2015 5:13 AM, "Peter Hutterer" <<a href="mailto:peter.hutterer@who-t.net">peter.hutterer@who-t.net</a>> wrote:<br>
><br>
> On Fri, Sep 04, 2015 at 11:47:09PM +0530, Seedo Eldho Paul wrote:<br>
> > xalloc terminates the program abruptly if the requested amount of<br>
> > memory couldn't be allocated. To insure that the errors are handled<br>
> > cleanly, use zalloc instead.<br>
> ><br>
> > Signed-off-by: Seedo Eldho Paul <<a href="mailto:seedoeldhopaul@gmail.com">seedoeldhopaul@gmail.com</a>><br>
> > ---<br>
> > tests/internal-screenshot-test.c | 11 ++++++-----<br>
><br>
> do you really care about correct OOM handling in a test?</p>
<p dir="ltr">Hi Peter,</p>
<p dir="ltr">Initially I posted a patch to remove the dead code if xzalloc is used: <a href="http://lists.freedesktop.org/archives/wayland-devel/2015-September/024151.html">http://lists.freedesktop.org/archives/wayland-devel/2015-September/024151.html</a>. Then Bryce wanted me to do it in this way instead.</p>
<p dir="ltr">SEEDO<br></p>
<p dir="ltr">><br>
> Cheers,<br>
> Peter<br>
><br>
> > 1 file changed, 6 insertions(+), 5 deletions(-)<br>
> ><br>
> > diff --git a/tests/internal-screenshot-test.c b/tests/internal-screenshot-test.c<br>
> > index e72a695..6b26e1a 100644<br>
> > --- a/tests/internal-screenshot-test.c<br>
> > +++ b/tests/internal-screenshot-test.c<br>
> > @@ -30,6 +30,7 @@<br>
> > #include <string.h> /* memcpy */<br>
> > #include <cairo.h><br>
> ><br>
> > +#include "zalloc.h"<br>
> > #include "weston-test-client-helper.h"<br>
> ><br>
> > char *server_parameters="--use-pixman --width=320 --height=240";<br>
> > @@ -92,9 +93,9 @@ load_surface_from_png(const char *fname)<br>
> > }<br>
> ><br>
> > /* Disguise the cairo surface in a weston test surface */<br>
> > - reference = xzalloc(sizeof *reference);<br>
> > + reference = zalloc(sizeof *reference);<br>
> > if (reference == NULL) {<br>
> > - perror("xzalloc reference");<br>
> > + perror("zalloc reference");<br>
> > cairo_surface_destroy(reference_cairo_surface);<br>
> > return NULL;<br>
> > }<br>
> > @@ -114,9 +115,9 @@ load_surface_from_png(const char *fname)<br>
> ><br>
> > /* Allocate new buffer for our weston reference, and copy the data from<br>
> > the cairo surface so we can destroy it */<br>
> > - reference->data = xzalloc(source_data_size);<br>
> > + reference->data = zalloc(source_data_size);<br>
> > if (reference->data == NULL) {<br>
> > - perror("xzalloc reference data");<br>
> > + perror("zalloc reference data");<br>
> > cairo_surface_destroy(reference_cairo_surface);<br>
> > free(reference);<br>
> > return NULL;<br>
> > @@ -143,7 +144,7 @@ static struct surface*<br>
> > create_screenshot_surface(struct client *client)<br>
> > {<br>
> > struct surface* screenshot;<br>
> > - screenshot = xzalloc(sizeof *screenshot);<br>
> > + screenshot = zalloc(sizeof *screenshot);<br>
> > if (screenshot == NULL)<br>
> > return NULL;<br>
> > screenshot->wl_buffer = create_shm_buffer(client,<br>
> > --<br>
> > 1.9.1<br>
> ><br>
> > _______________________________________________<br>
> > wayland-devel mailing list<br>
> > <a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
> > <a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
> ><br>
</p>