summaryrefslogtreecommitdiff
path: root/src/lib/edje/edje_entry.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-11-08 16:34:16 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-11-09 12:18:59 +0000
commit5641910ed24e1037d347ad991abdef328424b1ca (patch)
tree1f46d3e90a79e6c86fe0c59dee7bcfeb6bbd0ceb /src/lib/edje/edje_entry.c
parentdb3fe9b03f295ee36502052d82057e867afc39df (diff)
edje entry - be clearer and more efficient on string appending
using strncpy with strlen of the string you append is pointless. again... strcpy will do - but use memcpy to be exact and pre-compute sizing etc. only once. fixes warnings.
Diffstat (limited to '')
-rw-r--r--src/lib/edje/edje_entry.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/lib/edje/edje_entry.c b/src/lib/edje/edje_entry.c
index 1ad3c30b65..da0bc81674 100644
--- a/src/lib/edje/edje_entry.c
+++ b/src/lib/edje/edje_entry.c
@@ -361,6 +361,7 @@ _text_filter_format_prepend(Edje *ed, Entry *en, Evas_Textblock_Cursor *c, const
361 if (text2) 361 if (text2)
362 { 362 {
363 char *s, *markup_text; 363 char *s, *markup_text;
364 size_t size;
364 365
365 s = text2; 366 s = text2;
366 if (*s == '+') 367 if (*s == '+')
@@ -373,13 +374,14 @@ _text_filter_format_prepend(Edje *ed, Entry *en, Evas_Textblock_Cursor *c, const
373 free(text2); 374 free(text2);
374 return; 375 return;
375 } 376 }
376 markup_text = (char *)malloc(strlen(s) + 3); 377 size = strlen(s);
378 markup_text = (char *)malloc(size + 3);
377 if (markup_text) 379 if (markup_text)
378 { 380 {
379 *(markup_text) = '<'; 381 *(markup_text) = '<';
380 strncpy((markup_text + 1), s, strlen(s)); 382 memcpy((markup_text + 1), s, size);
381 *(markup_text + strlen(s) + 1) = '>'; 383 *(markup_text + size + 1) = '>';
382 *(markup_text + strlen(s) + 2) = '\0'; 384 *(markup_text + size + 2) = '\0';
383 } 385 }
384 } 386 }
385 else if (s[0] == '-') 387 else if (s[0] == '-')
@@ -392,26 +394,28 @@ _text_filter_format_prepend(Edje *ed, Entry *en, Evas_Textblock_Cursor *c, const
392 free(text2); 394 free(text2);
393 return; 395 return;
394 } 396 }
395 markup_text = (char *)malloc(strlen(s) + 4); 397 size = strlen(s);
398 markup_text = (char *)malloc(size + 4);
396 if (markup_text) 399 if (markup_text)
397 { 400 {
398 *(markup_text) = '<'; 401 *(markup_text) = '<';
399 *(markup_text + 1) = '/'; 402 *(markup_text + 1) = '/';
400 strncpy((markup_text + 2), s, strlen(s)); 403 memcpy((markup_text + 2), s, size);
401 *(markup_text + strlen(s) + 2) = '>'; 404 *(markup_text + size + 2) = '>';
402 *(markup_text + strlen(s) + 3) = '\0'; 405 *(markup_text + size + 3) = '\0';
403 } 406 }
404 } 407 }
405 else 408 else
406 { 409 {
407 markup_text = (char *)malloc(strlen(s) + 4); 410 size = strlen(s);
411 markup_text = (char *)malloc(size + 4);
408 if (markup_text) 412 if (markup_text)
409 { 413 {
410 *(markup_text) = '<'; 414 *(markup_text) = '<';
411 strncpy((markup_text + 1), s, strlen(s)); 415 memcpy((markup_text + 1), s, size);
412 *(markup_text + strlen(s) + 1) = '/'; 416 *(markup_text + size + 1) = '/';
413 *(markup_text + strlen(s) + 2) = '>'; 417 *(markup_text + size + 2) = '>';
414 *(markup_text + strlen(s) + 3) = '\0'; 418 *(markup_text + size + 3) = '\0';
415 } 419 }
416 } 420 }
417 free(text2); 421 free(text2);