hermet pushed a commit to branch master.

http://git.enlightenment.org/tools/enventor.git/commit/?id=5140ab5c648754f1c0300e488b603587b342cf9f

commit 5140ab5c648754f1c0300e488b603587b342cf9f
Author: Hermet Park <[email protected]>
Date:   Wed Jun 29 20:41:39 2016 +0900

    code refactoring.
    
    add a common memory fail message routine to reduce string usage.
---
 src/bin/file_browser.c       | 4 ++--
 src/bin/file_mgr.c           | 2 +-
 src/bin/file_tab.c           | 4 ++--
 src/bin/globals.c            | 5 +++++
 src/bin/goto.c               | 2 +-
 src/bin/menu.c               | 2 +-
 src/bin/newfile.c            | 2 +-
 src/bin/panes.c              | 2 +-
 src/bin/preference_setting.c | 2 +-
 src/bin/search.c             | 2 +-
 src/bin/setting.c            | 2 +-
 src/bin/statusbar.c          | 2 +-
 src/bin/text_setting.c       | 9 +++++----
 src/bin/tools.c              | 2 +-
 src/include/globals.h        | 1 +
 src/lib/Makefile.am          | 3 ++-
 src/lib/enventor_private.h   | 4 ++++
 src/lib/outline_obj.c        | 2 +-
 src/lib/redoundo.c           | 8 ++++----
 src/lib/syntax_color.c       | 2 +-
 src/lib/syntax_helper.c      | 2 +-
 src/lib/syntax_indent.c      | 2 +-
 22 files changed, 39 insertions(+), 27 deletions(-)

diff --git a/src/bin/file_browser.c b/src/bin/file_browser.c
index 94b1e94..f8aeb04 100644
--- a/src/bin/file_browser.c
+++ b/src/bin/file_browser.c
@@ -316,7 +316,7 @@ brows_file_create(const char *file_path, Eina_Bool 
create_sub_file_list)
    brows_file *file = calloc(1, sizeof(brows_file));
    if (!file)
      {
-        EINA_LOG_ERR("Failed to allocate Memory!");
+        mem_fail_msg();
         return NULL;
      }
 
@@ -599,7 +599,7 @@ file_browser_init(Evas_Object *parent)
    bd = calloc(1, sizeof(brows_data));
    if (!bd)
      {
-        EINA_LOG_ERR("Failed to allocate Memory!");
+        mem_fail_msg();
         return NULL;
      }
    g_bd = bd;
diff --git a/src/bin/file_mgr.c b/src/bin/file_mgr.c
index ee8764b..5434b22 100644
--- a/src/bin/file_mgr.c
+++ b/src/bin/file_mgr.c
@@ -190,7 +190,7 @@ file_mgr_init(void)
    file_mgr_data *fmd = calloc(1, sizeof(file_mgr_data));
    if (!fmd)
      {
-        EINA_LOG_ERR(_("Failed to allocate Memory!"));
+        mem_fail_msg();
         return;
      }
    g_fmd = fmd;
diff --git a/src/bin/file_tab.c b/src/bin/file_tab.c
index 2cef99a..befc6a0 100644
--- a/src/bin/file_tab.c
+++ b/src/bin/file_tab.c
@@ -39,7 +39,7 @@ Eina_Bool file_tab_it_add(Enventor_Item *enventor_it)
    fti = calloc(1, sizeof(file_tab_it));
    if (!fti)
      {
-        EINA_LOG_ERR("Failed to allocate Memory!");
+        mem_fail_msg();
         return EINA_FALSE;
      }
 
@@ -82,7 +82,7 @@ file_tab_init(Evas_Object *parent)
    file_data *fd = calloc(1, sizeof(file_data));
    if (!fd)
      {
-        EINA_LOG_ERR("Failed to allocate Memory!");
+        mem_fail_msg();
         return NULL;
      }
    g_fd = fd;
diff --git a/src/bin/globals.c b/src/bin/globals.c
index 14da88e..b1958ef 100644
--- a/src/bin/globals.c
+++ b/src/bin/globals.c
@@ -3,3 +3,8 @@
 const char *DEFAULT_EDC_FORMAT = "enventor_XXXXXX.edc";
 char EDJE_PATH[PATH_MAX];
 const char *ENVENTOR_NAME = "enventor";
+
+void mem_fail_msg(void)
+{
+   EINA_LOG_ERR("Failed to allocate Memory!");
+}
diff --git a/src/bin/goto.c b/src/bin/goto.c
index cf21872..f33b5a4 100644
--- a/src/bin/goto.c
+++ b/src/bin/goto.c
@@ -133,7 +133,7 @@ goto_open(void)
    gd = calloc(1, sizeof(goto_data));
    if (!gd)
      {
-        EINA_LOG_ERR(_("Failed to allocate Memory!"));
+        mem_fail_msg();
         return;
      }
    g_gd = gd;
diff --git a/src/bin/menu.c b/src/bin/menu.c
index b354637..2c684cb 100644
--- a/src/bin/menu.c
+++ b/src/bin/menu.c
@@ -610,7 +610,7 @@ menu_init(void)
    menu_data *md = calloc(1, sizeof(menu_data));
    if (!md)
      {
-        EINA_LOG_ERR(_("Failed to allocate Memory!"));
+        mem_fail_msg();
         return;
      }
    g_md = md;
diff --git a/src/bin/newfile.c b/src/bin/newfile.c
index 75fb583..ac01ccd 100644
--- a/src/bin/newfile.c
+++ b/src/bin/newfile.c
@@ -141,7 +141,7 @@ newfile_create(Evas_Object *parent, Evas_Smart_Cb 
selected_cb, void *data)
         nd = calloc(1, sizeof(new_data));
         if (!nd)
           {
-             EINA_LOG_ERR(_("Failed to allocate Memory!"));
+             mem_fail_msg();
              return NULL;
           }
         g_nd = nd;
diff --git a/src/bin/panes.c b/src/bin/panes.c
index 73d7b05..e8ac1e1 100644
--- a/src/bin/panes.c
+++ b/src/bin/panes.c
@@ -318,7 +318,7 @@ panes_init(Evas_Object *parent)
    panes_data *pd = malloc(sizeof(panes_data));
    if (!pd)
      {
-        EINA_LOG_ERR(_("Failed to allocate Memory!"));
+        mem_fail_msg();
         return NULL;
      }
    g_pd = pd;
diff --git a/src/bin/preference_setting.c b/src/bin/preference_setting.c
index 0d196d6..92e8b9d 100644
--- a/src/bin/preference_setting.c
+++ b/src/bin/preference_setting.c
@@ -309,7 +309,7 @@ preference_setting_init(void)
    preference_setting_data *psd = calloc(1, sizeof(preference_setting_data));
    if (!psd)
      {
-        EINA_LOG_ERR(_("Failed to allocate Memory!"));
+        mem_fail_msg();
         return NULL;
      }
    return psd;
diff --git a/src/bin/search.c b/src/bin/search.c
index de21277..82d7e3a 100644
--- a/src/bin/search.c
+++ b/src/bin/search.c
@@ -334,7 +334,7 @@ search_open(void)
    sd = calloc(1, sizeof(search_data));
    if (!sd)
      {
-        EINA_LOG_ERR(_("Failed to allocate Memory!"));
+        mem_fail_msg();
         return;
      }
    g_sd = sd;
diff --git a/src/bin/setting.c b/src/bin/setting.c
index 00a6e43..bb33b0d 100644
--- a/src/bin/setting.c
+++ b/src/bin/setting.c
@@ -184,7 +184,7 @@ setting_open(void)
    sd = calloc(1, sizeof(setting_data));
    if (!sd)
      {
-        EINA_LOG_ERR(_("Failed to allocate Memory!"));
+        mem_fail_msg();
         return;
      }
    g_sd = sd;
diff --git a/src/bin/statusbar.c b/src/bin/statusbar.c
index 4271370..2d135d7 100644
--- a/src/bin/statusbar.c
+++ b/src/bin/statusbar.c
@@ -309,7 +309,7 @@ stats_init(Evas_Object *parent)
    stats_data *sd = calloc(1, sizeof(stats_data));
    if (!sd)
      {
-        EINA_LOG_ERR(_("Failed to allocate Memory!"));
+        mem_fail_msg();
         return NULL;
      }
    g_sd = sd;
diff --git a/src/bin/text_setting.c b/src/bin/text_setting.c
index 0b7e08d..89d3d1e 100644
--- a/src/bin/text_setting.c
+++ b/src/bin/text_setting.c
@@ -403,7 +403,7 @@ color_keyword_list_create(char *syntax_template_str)
                                               sizeof(color_keyword));
    if (!color_keyword_list)
      {
-        EINA_LOG_ERR(_("Failed to allocate Memory!"));
+        mem_fail_msg();
         return NULL;
      }
 
@@ -454,7 +454,7 @@ syntax_template_format_create(text_setting_data *tsd)
    return tsd->syntax_template_format;
 
 err:
-   EINA_LOG_ERR(_("Failed to allocate Memory!"));
+   mem_fail_msg();
    if (utf8) free(utf8);
 
    eina_file_close(file);
@@ -485,7 +485,8 @@ syntax_template_create(text_setting_data *tsd)
    return tsd->syntax_template_str;
 
 err:
-   EINA_LOG_ERR(_("Failed to allocate Memory!"));
+   mem_fail_msg();
+
    if (syntax_template_format)
      {
         free(syntax_template_format);
@@ -994,7 +995,7 @@ text_setting_init(void)
    text_setting_data *tsd = calloc(1, sizeof(text_setting_data));
    if (!tsd)
      {
-        EINA_LOG_ERR(_("Failed to allocate Memory!"));
+        mem_fail_msg();
         return NULL;
      }
    return tsd;
diff --git a/src/bin/tools.c b/src/bin/tools.c
index e797986..bc6c2ee 100644
--- a/src/bin/tools.c
+++ b/src/bin/tools.c
@@ -191,7 +191,7 @@ tools_init(Evas_Object *parent)
    td = calloc(1, sizeof(tools_data));
    if (!td)
      {
-        EINA_LOG_ERR(_("Failed to allocate Memory!"));
+        mem_fail_msg();
         return;
      }
    g_td = td;
diff --git a/src/include/globals.h b/src/include/globals.h
index 1d29b42..368725d 100644
--- a/src/include/globals.h
+++ b/src/include/globals.h
@@ -2,3 +2,4 @@ extern const char *DEFAULT_EDC_FORMAT;
 extern char EDJE_PATH[PATH_MAX];
 extern Eina_Prefix *PREFIX;
 extern const char *ENVENTOR_NAME;
+void mem_fail_msg(void);
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index f30a0a9..11fd48c 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -44,7 +44,8 @@ libenventor_la_SOURCES = \
    edj_mgr.c \
    edj_viewer.c \
    dummy_obj.c \
-   outline_obj.c
+   outline_obj.c \
+       util.c
 
 libenventor_la_CFLAGS = @ENVENTOR_CFLAGS@
 libenventor_la_LIBADD = @ENVENTOR_LIBS@
diff --git a/src/lib/enventor_private.h b/src/lib/enventor_private.h
index ea57c4d..b9b19f3 100644
--- a/src/lib/enventor_private.h
+++ b/src/lib/enventor_private.h
@@ -277,4 +277,8 @@ redoundo_data *edit_redoundo_get(edit_data *ed);
 void edit_selection_region_center_set(edit_data *ed, int start, int end);
 const char *edit_file_get(edit_data *ed);
 
+
+/* util */
+void mem_fail_msg(void);
+
 #endif
diff --git a/src/lib/outline_obj.c b/src/lib/outline_obj.c
index 15b74e7..eb4d781 100644
--- a/src/lib/outline_obj.c
+++ b/src/lib/outline_obj.c
@@ -183,7 +183,7 @@ outline_obj_new(Evas_Object *layout)
    outline = calloc(1, sizeof(outline_obj));
    if (!outline)
      {
-        EINA_LOG_ERR("Failed to allocate Memory!");
+        mem_fail_msg();
         return;
      }
 
diff --git a/src/lib/redoundo.c b/src/lib/redoundo.c
index 34efef9..681cdff 100644
--- a/src/lib/redoundo.c
+++ b/src/lib/redoundo.c
@@ -137,7 +137,7 @@ entry_changed_user_cb(void *data, Evas_Object *obj 
EINA_UNUSED,
    diff_data *diff = calloc(1, sizeof(diff_data));
    if (!diff)
      {
-        EINA_LOG_ERR("Failed to allocate Memory!");
+        mem_fail_msg();
         return;
      }
 
@@ -357,7 +357,7 @@ redoundo_text_push(redoundo_data *rd, const char *text, int 
pos, int length,
    diff_data *diff = calloc(1, sizeof(diff_data));
    if (!diff)
      {
-        EINA_LOG_ERR("Failed to allocate Memory!");
+        mem_fail_msg();
         return;
      }
 
@@ -401,7 +401,7 @@ redoundo_init(edit_data *ed, Enventor_Object *enventor)
    redoundo_data *rd = calloc(1, sizeof(redoundo_data));
    if (!rd)
      {
-        EINA_LOG_ERR("Failed to allocate Memory!");
+        mem_fail_msg();
         return NULL;
      }
 
@@ -461,7 +461,7 @@ redoundo_text_relative_push(redoundo_data *rd, const char 
*text)
    diff_data *diff = malloc(sizeof(diff_data));
    if (!diff)
      {
-        EINA_LOG_ERR("Failed to allocate Memory!");
+        mem_fail_msg();
         return;
      }
 
diff --git a/src/lib/syntax_color.c b/src/lib/syntax_color.c
index 2607869..dc853eb 100644
--- a/src/lib/syntax_color.c
+++ b/src/lib/syntax_color.c
@@ -696,7 +696,7 @@ color_init(Eina_Strbuf *strbuf)
    color_data *cd = calloc(1, sizeof(color_data));
    if (!cd)
      {
-        EINA_LOG_ERR("Failed to allocate Memory!");
+        mem_fail_msg();
         return NULL;
      }
 
diff --git a/src/lib/syntax_helper.c b/src/lib/syntax_helper.c
index e655a29..b09a1b4 100644
--- a/src/lib/syntax_helper.c
+++ b/src/lib/syntax_helper.c
@@ -40,7 +40,7 @@ syntax_init(edit_data *ed)
    syntax_helper *sh = malloc(sizeof(syntax_helper));
    if (!sh)
      {
-        EINA_LOG_ERR("Failed to allocate Memory!");
+        mem_fail_msg();
         return NULL;
      }
    sh->strbuf = eina_strbuf_new();
diff --git a/src/lib/syntax_indent.c b/src/lib/syntax_indent.c
index e041243..21b83ba 100644
--- a/src/lib/syntax_indent.c
+++ b/src/lib/syntax_indent.c
@@ -572,7 +572,7 @@ indent_init(Eina_Strbuf *strbuf, edit_data *ed)
    indent_data *id = malloc(sizeof(indent_data));
    if (!id)
      {
-        EINA_LOG_ERR("Failed to allocate Memory!");
+        mem_fail_msg();
         return NULL;
      }
    id->strbuf = strbuf;

-- 


Reply via email to