thiep pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=780b96442720af0e77d7e4da3209d88921e1b647

commit 780b96442720af0e77d7e4da3209d88921e1b647
Author: Thiep Ha <thie...@gmail.com>
Date:   Tue May 10 15:13:27 2016 +0900

    elm test dnd: replace strcat with eina_strbuf
    
    replace strcat with eina_strbuf.
---
 src/bin/elementary/test_dnd.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/src/bin/elementary/test_dnd.c b/src/bin/elementary/test_dnd.c
index faeee2e..3b44c2b 100644
--- a/src/bin/elementary/test_dnd.c
+++ b/src/bin/elementary/test_dnd.c
@@ -61,21 +61,14 @@ _drag_data_build(Eina_List **items)
    const char *drag_data = NULL;
    if (*items)
      {
+        Eina_Strbuf *str;
         Eina_List *l;
         Elm_Object_Item *it;
         const char *t;
-        unsigned int len = 0;
         int i = 0;
 
-        EINA_LIST_FOREACH(*items, l, it)
-          {
-             t = (char *)elm_object_item_data_get(it);
-             if (t)
-               len += strlen(t);
-          }
-
-        drag_data = malloc(len + eina_list_count(*items) * (FILESEP_LEN + 1));
-        strcpy((char *) drag_data, "");
+        str = eina_strbuf_new();
+        if (!str) return NULL;
 
         /* drag data in form: file://URI1\nfile://URI2 */
         EINA_LIST_FOREACH(*items, l, it)
@@ -84,12 +77,14 @@ _drag_data_build(Eina_List **items)
              if (t)
                {
                   if (i > 0)
-                    strcat((char *) drag_data, "\n");
-                  strcat((char *) drag_data, FILESEP);
-                  strcat((char *) drag_data, t);
+                    eina_strbuf_append(str, "\n");
+                  eina_strbuf_append(str, FILESEP);
+                  eina_strbuf_append(str, t);
                   i++;
                }
           }
+        drag_data = eina_strbuf_string_steal(str);
+        eina_strbuf_free(str);
      }
    return drag_data;
 }

-- 


Reply via email to