summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean.guyomarch@openwide.fr>2015-10-15 11:29:51 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-12-01 12:15:32 -0800
commit4ab8471ef05f42269a7bed02250801577b8bbd1a (patch)
tree890c8687212c7f10d025c8e43c579039eb2e4c23
parent614274f85768e4ae92fe3e37210c9e1046e3921f (diff)
ecore_x: factorize multiple calls to strlen()
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_events.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lib/ecore_x/xlib/ecore_x_events.c b/src/lib/ecore_x/xlib/ecore_x_events.c
index a560bb8..5b0e19f 100644
--- a/src/lib/ecore_x/xlib/ecore_x_events.c
+++ b/src/lib/ecore_x/xlib/ecore_x_events.c
@@ -334,6 +334,7 @@ _ecore_key_press(int event,
334 KeySym sym; 334 KeySym sym;
335 XComposeStatus status; 335 XComposeStatus status;
336 int val; 336 int val;
337 int key_len, keyname_len, compose_len;
337 338
338 _ecore_x_last_event_mouse_move = 0; 339 _ecore_x_last_event_mouse_move = 0;
339 keyname = XKeysymToString(_ecore_x_XKeycodeToKeysym(xevent->display, 340 keyname = XKeysymToString(_ecore_x_XKeycodeToKeysym(xevent->display,
@@ -370,14 +371,18 @@ _ecore_key_press(int event,
370 if (!key) 371 if (!key)
371 key = keyname; 372 key = keyname;
372 373
373 e = calloc(1, sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) + 374 key_len = strlen(key);
374 (compose ? strlen(compose) : 0) + 3); 375 keyname_len = strlen(keyname);
376 compose_len = (compose) ? strlen(compose) : 0;
377
378 e = calloc(1, sizeof(Ecore_Event_Key) + key_len + keyname_len +
379 compose_len + 3);
375 if (!e) 380 if (!e)
376 goto on_error; 381 goto on_error;
377 382
378 e->keyname = (char *)(e + 1); 383 e->keyname = (char *)(e + 1);
379 e->key = e->keyname + strlen(keyname) + 1; 384 e->key = e->keyname + keyname_len + 1;
380 e->compose = (compose) ? e->key + strlen(key) + 1 : NULL; 385 e->compose = (compose) ? e->key + key_len + 1 : NULL;
381 e->string = e->compose; 386 e->string = e->compose;
382 387
383 strcpy((char *)e->keyname, keyname); 388 strcpy((char *)e->keyname, keyname);