hermet pushed a commit to branch master.

http://git.enlightenment.org/tools/enventor.git/commit/?id=872a79e87dc0600196196b023c8f35bce2c20476

commit 872a79e87dc0600196196b023c8f35bce2c20476
Author: Hermet Park <her...@hermet.pe.kr>
Date:   Tue Feb 2 16:38:51 2016 +0900

    fix incorrect memory allocation.
    
    eina_inarray copies it's element memory when it have them.
    we don't need to allocate element memory dynamically to push into it.
    
    @fix
---
 src/lib/syntax_color.c | 31 +++++++++----------------------
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/src/lib/syntax_color.c b/src/lib/syntax_color.c
index 5a44d9a..6285aae 100644
--- a/src/lib/syntax_color.c
+++ b/src/lib/syntax_color.c
@@ -123,7 +123,7 @@ color_load()
 static void
 color_table_init(color_data *cd)
 {
-   color_tuple *tuple;
+   color_tuple tuple;
    int i;
    Eina_List *l;
    char *key;
@@ -160,16 +160,9 @@ color_table_init(color_data *cd)
                   eina_hash_add(cd->color_hash, tmp, inarray);
                }
 
-             tuple = malloc(sizeof(color_tuple));
-             if (!tuple)
-               {
-                  EINA_LOG_ERR("Failed to allocate Memory!");
-                  continue;
-               }
-             tuple->col = cd->cols[i];
-             tuple->key = eina_stringshare_add(key);
-             eina_inarray_push(inarray, tuple);
-             free(tuple);
+             tuple.col = cd->cols[i];
+             tuple.key = eina_stringshare_add(key);
+             eina_inarray_push(inarray, &tuple);
           }
         eina_list_free(scg->colors[i].keys);
      }
@@ -198,18 +191,12 @@ macro_key_push(color_data *cd, char *str)
         eina_hash_add(cd->color_hash, tmp, inarray);
      }
 
-   color_tuple *tuple = malloc(sizeof(color_tuple));
-   if (!tuple)
-     {
-        EINA_LOG_ERR("Failed to allocate Memory!");
-        if (cut) free(key);
-        return;
-     }
-   tuple->col = cd->col_macro;
-   tuple->key = eina_stringshare_add(key);
-   eina_inarray_push(inarray, tuple);
+   color_tuple tuple;
+   tuple.col = cd->col_macro;
+   tuple.key = eina_stringshare_add(key);
+   eina_inarray_push(inarray, &tuple);
 
-   cd->macros = eina_list_append(cd->macros, eina_stringshare_add(tuple->key));
+   cd->macros = eina_list_append(cd->macros, eina_stringshare_add(tuple.key));
 
    if (cut) free(key);
 }

-- 


Reply via email to