summaryrefslogtreecommitdiff
path: root/src/lib/ecore_wayland
diff options
context:
space:
mode:
authorBryce Harrington <bryce@osg.samsung.com>2015-03-17 20:30:32 -0400
committerChris Michael <cp.michael@samsung.com>2015-03-17 20:30:32 -0400
commita2e301db71b93fb5981c6aa3f7988fc220ec5d0b (patch)
tree5489bccfdf3c562065582d73677e18d93255bdf0 /src/lib/ecore_wayland
parentc0bc1be83e55de2b0ed0dc1ad24a8e43461cad5f (diff)
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
Diffstat (limited to 'src/lib/ecore_wayland')
-rw-r--r--src/lib/ecore_wayland/ecore_wl.c4
-rw-r--r--src/lib/ecore_wayland/ecore_wl_output.c4
-rw-r--r--src/lib/ecore_wayland/ecore_wl_window.c4
3 files changed, 3 insertions, 9 deletions
diff --git a/src/lib/ecore_wayland/ecore_wl.c b/src/lib/ecore_wayland/ecore_wl.c
index b6e95ce..49d7f6c 100644
--- a/src/lib/ecore_wayland/ecore_wl.c
+++ b/src/lib/ecore_wayland/ecore_wl.c
@@ -162,14 +162,12 @@ ecore_wl_init(const char *name)
162 ECORE_WL_EVENT_INTERFACES_BOUND = ecore_event_type_new(); 162 ECORE_WL_EVENT_INTERFACES_BOUND = ecore_event_type_new();
163 } 163 }
164 164
165 if (!(_ecore_wl_disp = malloc(sizeof(Ecore_Wl_Display)))) 165 if (!(_ecore_wl_disp = calloc(1, sizeof(Ecore_Wl_Display))))
166 { 166 {
167 ERR("Could not allocate memory for Ecore_Wl_Display structure"); 167 ERR("Could not allocate memory for Ecore_Wl_Display structure");
168 goto exit_ecore_disp; 168 goto exit_ecore_disp;
169 } 169 }
170 170
171 memset(_ecore_wl_disp, 0, sizeof(Ecore_Wl_Display));
172
173 if (!(_ecore_wl_disp->wl.display = wl_display_connect(name))) 171 if (!(_ecore_wl_disp->wl.display = wl_display_connect(name)))
174 { 172 {
175 ERR("Could not connect to Wayland display"); 173 ERR("Could not connect to Wayland display");
diff --git a/src/lib/ecore_wayland/ecore_wl_output.c b/src/lib/ecore_wayland/ecore_wl_output.c
index 28c430f..412611b 100644
--- a/src/lib/ecore_wayland/ecore_wl_output.c
+++ b/src/lib/ecore_wayland/ecore_wl_output.c
@@ -73,9 +73,7 @@ _ecore_wl_output_add(Ecore_Wl_Display *ewd, unsigned int id)
73 73
74 LOGFN(__FILE__, __LINE__, __FUNCTION__); 74 LOGFN(__FILE__, __LINE__, __FUNCTION__);
75 75
76 if (!(output = malloc(sizeof(Ecore_Wl_Output)))) return; 76 if (!(output = calloc(1, sizeof(Ecore_Wl_Output)))) return;
77
78 memset(output, 0, sizeof(Ecore_Wl_Output));
79 77
80 output->display = ewd; 78 output->display = ewd;
81 79
diff --git a/src/lib/ecore_wayland/ecore_wl_window.c b/src/lib/ecore_wayland/ecore_wl_window.c
index 05f3832..8f2f192 100644
--- a/src/lib/ecore_wayland/ecore_wl_window.c
+++ b/src/lib/ecore_wayland/ecore_wl_window.c
@@ -74,14 +74,12 @@ ecore_wl_window_new(Ecore_Wl_Window *parent, int x, int y, int w, int h, int buf
74 74
75 LOGFN(__FILE__, __LINE__, __FUNCTION__); 75 LOGFN(__FILE__, __LINE__, __FUNCTION__);
76 76
77 if (!(win = malloc(sizeof(Ecore_Wl_Window)))) 77 if (!(win = calloc(1, sizeof(Ecore_Wl_Window))))
78 { 78 {
79 ERR("Failed to allocate an Ecore Wayland Window"); 79 ERR("Failed to allocate an Ecore Wayland Window");
80 return NULL; 80 return NULL;
81 } 81 }
82 82
83 memset(win, 0, sizeof(Ecore_Wl_Window));
84
85 win->display = _ecore_wl_disp; 83 win->display = _ecore_wl_disp;
86 win->parent = parent; 84 win->parent = parent;
87 win->allocation.x = x; 85 win->allocation.x = x;