Re: [PATCH 4/5] clients: Use xzalloc instead of xcalloc when allocating single element

2014-05-09 Thread Kristian Høgsberg
On Wed, May 07, 2014 at 02:13:11AM +, Bryce W. Harrington wrote:
> 
> Signed-off-by: Bryce Harrington 
> ---
>  clients/desktop-shell.c |2 +-
>  clients/editor.c|2 +-
>  clients/fullscreen.c|2 +-
>  clients/subsurfaces.c   |6 +++---
>  clients/window.c|4 ++--
>  clients/wscreensaver.c  |2 +-
>  6 files changed, 9 insertions(+), 9 deletions(-)

Oh, didn't see this one when I replied to the earlier xcalloc patch.
I don't think we have a single place where we actually need xcalloc, so
I'd rather not add it at all.

Kristian

> diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
> index a3b2534..0b8d08b 100644
> --- a/clients/desktop-shell.c
> +++ b/clients/desktop-shell.c
> @@ -1217,7 +1217,7 @@ create_output(struct desktop *desktop, uint32_t id)
>  {
>   struct output *output;
>  
> - output = xcalloc(1, sizeof *output);
> + output = xzalloc(sizeof *output);
>   output->output =
>   display_bind(desktop->display, id, &wl_output_interface, 2);
>   output->server_output_id = id;
> diff --git a/clients/editor.c b/clients/editor.c
> index b439d9e..bda3e91 100644
> --- a/clients/editor.c
> +++ b/clients/editor.c
> @@ -559,7 +559,7 @@ text_entry_create(struct editor *editor, const char *text)
>  {
>   struct text_entry *entry;
>  
> - entry = xcalloc(1, sizeof *entry);
> + entry = xzalloc(sizeof *entry);
>   entry->widget = widget_add_widget(editor->widget, entry);
>   entry->window = editor->window;
>   entry->text = strdup(text);
> diff --git a/clients/fullscreen.c b/clients/fullscreen.c
> index ad7c703..8f41455 100644
> --- a/clients/fullscreen.c
> +++ b/clients/fullscreen.c
> @@ -480,7 +480,7 @@ output_handler(struct output *output, void *data)
>   if (fsout->output == output)
>   return;
>  
> - fsout = xcalloc(1, sizeof *fsout);
> + fsout = xzalloc(sizeof *fsout);
>   fsout->output = output;
>   wl_list_insert(&fullscreen->output_list, &fsout->link);
>  }
> diff --git a/clients/subsurfaces.c b/clients/subsurfaces.c
> index a683787..1ed698b 100644
> --- a/clients/subsurfaces.c
> +++ b/clients/subsurfaces.c
> @@ -212,7 +212,7 @@ egl_state_create(struct wl_display *display)
>   EGLint major, minor, n;
>   EGLBoolean ret;
>  
> - egl = xcalloc(1, sizeof *egl);
> + egl = xzalloc(sizeof *egl);
>   egl->dpy = eglGetDisplay(display);
>   assert(egl->dpy);
>  
> @@ -492,7 +492,7 @@ triangle_create(struct window *window, struct egl_state 
> *egl)
>  {
>   struct triangle *tri;
>  
> - tri = xcalloc(1, sizeof *tri);
> + tri = xzalloc(sizeof *tri);
>   tri->egl = egl;
>   tri->widget = window_add_subsurface(window, tri,
>   int_to_mode(option_triangle_mode));
> @@ -712,7 +712,7 @@ demoapp_create(struct display *display)
>  {
>   struct demoapp *app;
>  
> - app = xcalloc(1, sizeof *app);
> + app = xzalloc(sizeof *app);
>   app->egl = egl_state_create(display_get_display(display));
>  
>   app->display = display;
> diff --git a/clients/window.c b/clients/window.c
> index 2212351..a103530 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -1139,7 +1139,7 @@ shm_surface_create(struct display *display, struct 
> wl_surface *wl_surface,
>   struct shm_surface *surface;
>   DBG_OBJ(wl_surface, "\n");
>  
> - surface = xcalloc(1, sizeof *surface);
> + surface = xzalloc(sizeof *surface);
>   surface->base.prepare = shm_surface_prepare;
>   surface->base.swap = shm_surface_swap;
>   surface->base.acquire = shm_surface_acquire;
> @@ -4331,7 +4331,7 @@ surface_create(struct window *window)
>   struct display *display = window->display;
>   struct surface *surface;
>  
> - surface = xcalloc(1, sizeof *surface);
> + surface = xzalloc(sizeof *surface);
>   surface->window = window;
>   surface->surface = wl_compositor_create_surface(display->compositor);
>   surface->buffer_scale = 1;
> diff --git a/clients/wscreensaver.c b/clients/wscreensaver.c
> index 1070c07..d87d040 100644
> --- a/clients/wscreensaver.c
> +++ b/clients/wscreensaver.c
> @@ -175,7 +175,7 @@ create_wscreensaver_instance(struct wscreensaver 
> *screensaver,
>   struct ModeInfo *mi;
>   struct rectangle drawarea;
>  
> - mi = xcalloc(1, sizeof *mi);
> + mi = xzalloc(sizeof *mi);
>  
>   if (demo_mode)
>   mi->window = window_create(screensaver->display);
> -- 
> 1.7.9.5
> ___
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH 4/5] clients: Use xzalloc instead of xcalloc when allocating single element

2014-05-06 Thread Bryce W. Harrington

Signed-off-by: Bryce Harrington 
---
 clients/desktop-shell.c |2 +-
 clients/editor.c|2 +-
 clients/fullscreen.c|2 +-
 clients/subsurfaces.c   |6 +++---
 clients/window.c|4 ++--
 clients/wscreensaver.c  |2 +-
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index a3b2534..0b8d08b 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -1217,7 +1217,7 @@ create_output(struct desktop *desktop, uint32_t id)
 {
struct output *output;
 
-   output = xcalloc(1, sizeof *output);
+   output = xzalloc(sizeof *output);
output->output =
display_bind(desktop->display, id, &wl_output_interface, 2);
output->server_output_id = id;
diff --git a/clients/editor.c b/clients/editor.c
index b439d9e..bda3e91 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -559,7 +559,7 @@ text_entry_create(struct editor *editor, const char *text)
 {
struct text_entry *entry;
 
-   entry = xcalloc(1, sizeof *entry);
+   entry = xzalloc(sizeof *entry);
entry->widget = widget_add_widget(editor->widget, entry);
entry->window = editor->window;
entry->text = strdup(text);
diff --git a/clients/fullscreen.c b/clients/fullscreen.c
index ad7c703..8f41455 100644
--- a/clients/fullscreen.c
+++ b/clients/fullscreen.c
@@ -480,7 +480,7 @@ output_handler(struct output *output, void *data)
if (fsout->output == output)
return;
 
-   fsout = xcalloc(1, sizeof *fsout);
+   fsout = xzalloc(sizeof *fsout);
fsout->output = output;
wl_list_insert(&fullscreen->output_list, &fsout->link);
 }
diff --git a/clients/subsurfaces.c b/clients/subsurfaces.c
index a683787..1ed698b 100644
--- a/clients/subsurfaces.c
+++ b/clients/subsurfaces.c
@@ -212,7 +212,7 @@ egl_state_create(struct wl_display *display)
EGLint major, minor, n;
EGLBoolean ret;
 
-   egl = xcalloc(1, sizeof *egl);
+   egl = xzalloc(sizeof *egl);
egl->dpy = eglGetDisplay(display);
assert(egl->dpy);
 
@@ -492,7 +492,7 @@ triangle_create(struct window *window, struct egl_state 
*egl)
 {
struct triangle *tri;
 
-   tri = xcalloc(1, sizeof *tri);
+   tri = xzalloc(sizeof *tri);
tri->egl = egl;
tri->widget = window_add_subsurface(window, tri,
int_to_mode(option_triangle_mode));
@@ -712,7 +712,7 @@ demoapp_create(struct display *display)
 {
struct demoapp *app;
 
-   app = xcalloc(1, sizeof *app);
+   app = xzalloc(sizeof *app);
app->egl = egl_state_create(display_get_display(display));
 
app->display = display;
diff --git a/clients/window.c b/clients/window.c
index 2212351..a103530 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -1139,7 +1139,7 @@ shm_surface_create(struct display *display, struct 
wl_surface *wl_surface,
struct shm_surface *surface;
DBG_OBJ(wl_surface, "\n");
 
-   surface = xcalloc(1, sizeof *surface);
+   surface = xzalloc(sizeof *surface);
surface->base.prepare = shm_surface_prepare;
surface->base.swap = shm_surface_swap;
surface->base.acquire = shm_surface_acquire;
@@ -4331,7 +4331,7 @@ surface_create(struct window *window)
struct display *display = window->display;
struct surface *surface;
 
-   surface = xcalloc(1, sizeof *surface);
+   surface = xzalloc(sizeof *surface);
surface->window = window;
surface->surface = wl_compositor_create_surface(display->compositor);
surface->buffer_scale = 1;
diff --git a/clients/wscreensaver.c b/clients/wscreensaver.c
index 1070c07..d87d040 100644
--- a/clients/wscreensaver.c
+++ b/clients/wscreensaver.c
@@ -175,7 +175,7 @@ create_wscreensaver_instance(struct wscreensaver 
*screensaver,
struct ModeInfo *mi;
struct rectangle drawarea;
 
-   mi = xcalloc(1, sizeof *mi);
+   mi = xzalloc(sizeof *mi);
 
if (demo_mode)
mi->window = window_create(screensaver->display);
-- 
1.7.9.5
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel