ecore-wayland: Use calloc rather than malloc+memset

Summary:
In addition to being fewer lines of code,
malloc + memset to 0 is slower than calloc.  See
http://stackoverflow.com/questions/2688466/why-mallocmemset-is-slower-than-calloc

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>

Reviewers: zmike, cedric, devilhorns

Reviewed By: devilhorns

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D2182
This commit is contained in:
Bryce Harrington 2015-03-17 20:30:32 -04:00 committed by Chris Michael
parent c0bc1be83e
commit a2e301db71
3 changed files with 3 additions and 9 deletions

View File

@ -162,14 +162,12 @@ ecore_wl_init(const char *name)
ECORE_WL_EVENT_INTERFACES_BOUND = ecore_event_type_new();
}
if (!(_ecore_wl_disp = malloc(sizeof(Ecore_Wl_Display))))
if (!(_ecore_wl_disp = calloc(1, sizeof(Ecore_Wl_Display))))
{
ERR("Could not allocate memory for Ecore_Wl_Display structure");
goto exit_ecore_disp;
}
memset(_ecore_wl_disp, 0, sizeof(Ecore_Wl_Display));
if (!(_ecore_wl_disp->wl.display = wl_display_connect(name)))
{
ERR("Could not connect to Wayland display");

View File

@ -73,9 +73,7 @@ _ecore_wl_output_add(Ecore_Wl_Display *ewd, unsigned int id)
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!(output = malloc(sizeof(Ecore_Wl_Output)))) return;
memset(output, 0, sizeof(Ecore_Wl_Output));
if (!(output = calloc(1, sizeof(Ecore_Wl_Output)))) return;
output->display = ewd;

View File

@ -74,14 +74,12 @@ ecore_wl_window_new(Ecore_Wl_Window *parent, int x, int y, int w, int h, int buf
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!(win = malloc(sizeof(Ecore_Wl_Window))))
if (!(win = calloc(1, sizeof(Ecore_Wl_Window))))
{
ERR("Failed to allocate an Ecore Wayland Window");
return NULL;
}
memset(win, 0, sizeof(Ecore_Wl_Window));
win->display = _ecore_wl_disp;
win->parent = parent;
win->allocation.x = x;