hermet pushed a commit to branch master. http://git.enlightenment.org/tools/enventor.git/commit/?id=93f2148e433fcb11bc8b7e51762de1cbb9a1797c
commit 93f2148e433fcb11bc8b7e51762de1cbb9a1797c Author: Jaehyun Cho <[email protected]> Date: Mon Jul 28 13:40:58 2014 +0900 enventor: Add log messages for memory allocation error Summary: Add log messages for memory allocation error Reviewers: Hermet Differential Revision: https://phab.enlightenment.org/D1245 --- AUTHORS | 1 + src/bin/auto_comp.c | 5 +++++ src/bin/base_gui.c | 5 +++++ src/bin/config_data.c | 6 +++++- src/bin/ctxpopup.c | 12 ++++++++++-- src/bin/dummy_obj.c | 11 ++++++++++- src/bin/edc_editor.c | 10 ++++++++++ src/bin/edc_parser.c | 24 ++++++++++++++++++++++-- src/bin/edj_mgr.c | 11 ++++++++++- src/bin/edj_viewer.c | 5 +++++ src/bin/goto.c | 5 +++++ src/bin/indent.c | 5 +++++ src/bin/menu.c | 5 +++++ src/bin/newfile.c | 5 +++++ src/bin/panes.c | 5 +++++ src/bin/search.c | 5 +++++ src/bin/statusbar.c | 5 +++++ src/bin/syntax_color.c | 16 ++++++++++++++++ src/bin/syntax_helper.c | 5 +++++ 19 files changed, 139 insertions(+), 7 deletions(-) diff --git a/AUTHORS b/AUTHORS index 1c3496d..794a297 100644 --- a/AUTHORS +++ b/AUTHORS @@ -6,3 +6,4 @@ Ryuan Choi <[email protected]> Jihoon Kim <[email protected]> The Rasterman (Carsten Haitzler) <[email protected]> Kateryna Fesyna <[email protected]> +JaeHyun Jo <[email protected]> diff --git a/src/bin/auto_comp.c b/src/bin/auto_comp.c index e312b24..baabcec 100644 --- a/src/bin/auto_comp.c +++ b/src/bin/auto_comp.c @@ -484,6 +484,11 @@ void autocomp_init(Evas_Object *parent) { autocomp_data *ad = calloc(1, sizeof(autocomp_data)); + if (!ad) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return; + } ad->init_thread = ecore_thread_run(init_thread_cb, init_thread_end_cb, init_thread_cancel_cb, ad); ad->anchor = elm_button_add(parent); diff --git a/src/bin/base_gui.c b/src/bin/base_gui.c index df25b9e..f5e7d4b 100644 --- a/src/bin/base_gui.c +++ b/src/bin/base_gui.c @@ -128,6 +128,11 @@ base_gui_init() char buf[PATH_MAX]; base_data *bd = calloc(1, sizeof(base_data)); + if (!bd) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return EINA_FALSE; + } g_bd = bd; //Window diff --git a/src/bin/config_data.c b/src/bin/config_data.c index 2b9db44..fd14c80 100644 --- a/src/bin/config_data.c +++ b/src/bin/config_data.c @@ -122,7 +122,11 @@ config_load() if (!cd) { cd = calloc(1, sizeof(config_data)); - + if (!cd) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return NULL; + } cd->font_size = 1.0f; cd->view_scale = 1; cd->stats_bar = EINA_TRUE; diff --git a/src/bin/ctxpopup.c b/src/bin/ctxpopup.c index 7fb0c66..0fdfdc8 100644 --- a/src/bin/ctxpopup.c +++ b/src/bin/ctxpopup.c @@ -244,7 +244,11 @@ ctxpopup_candidate_list_create(edit_data *ed, attr_value *attr, //ctxpopup data ctxpopup_data *ctxdata = malloc(sizeof(ctxpopup_data)); - if (!ctxdata) goto err; + if (!ctxdata) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + goto err; + } ctxdata->selected_cb = ctxpopup_selected_cb; ctxdata->data = ed; evas_object_data_set(ctxpopup, "ctxpopup_data", ctxdata); @@ -330,7 +334,11 @@ ctxpopup_img_preview_create(edit_data *ed, ELM_CTXPOPUP_DIRECTION_RIGHT); //ctxpopup data ctxpopup_data *ctxdata = malloc(sizeof(ctxpopup_data)); - if (!ctxdata) return NULL; + if (!ctxdata) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return NULL; + } ctxdata->relay_cb = ctxpopup_relay_cb; ctxdata->data = ed; ctxdata->ctxpopup = ctxpopup; diff --git a/src/bin/dummy_obj.c b/src/bin/dummy_obj.c index fb3379a..4928d02 100644 --- a/src/bin/dummy_obj.c +++ b/src/bin/dummy_obj.c @@ -68,7 +68,11 @@ dummy_objs_update(dummy_obj *dummy) continue; po = malloc(sizeof(part_obj)); - if (!po) continue; + if (!po) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + continue; + } //New part. Add fake object. Evas_Object *obj = edje_object_add(dummy->layout); @@ -115,6 +119,11 @@ dummy_obj_new(Evas_Object *layout) if (dummy) return; dummy = calloc(1, sizeof(dummy_obj)); + if (!dummy) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return; + } Ecore_Animator *animator = ecore_animator_add(animator_cb, dummy); evas_object_data_set(layout, DUMMYOBJ, dummy); diff --git a/src/bin/edc_editor.c b/src/bin/edc_editor.c index c2673d2..4072328 100644 --- a/src/bin/edc_editor.c +++ b/src/bin/edc_editor.c @@ -205,6 +205,11 @@ syntax_color_full_update(edit_data *ed, Eina_Bool thread) if (thread) { syntax_color_td *td = malloc(sizeof(syntax_color_td)); + if (!td) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return; + } td->ed = ed; Evas_Object *tb = elm_entry_textblock_get(ed->en_edit); td->text = (char *) evas_object_textblock_text_markup_get(tb); @@ -916,6 +921,11 @@ edit_init(Evas_Object *parent) syntax_helper *sh = syntax_init(); edit_data *ed = calloc(1, sizeof(edit_data)); + if (!ed) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return NULL; + } ed->pd = pd; ed->sh = sh; diff --git a/src/bin/edc_parser.c b/src/bin/edc_parser.c index 4aceb5b..59e0d35 100644 --- a/src/bin/edc_parser.c +++ b/src/bin/edc_parser.c @@ -725,7 +725,11 @@ parser_cur_group_name_get(parser_data *pd, Evas_Object *entry, if (pd->thread) ecore_thread_cancel(pd->thread); cur_name_td *td = calloc(1, sizeof(cur_name_td)); - if (!td) return; + if (!td) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return; + } const char *text = elm_entry_entry_get(entry); if (!text) return; @@ -753,7 +757,11 @@ parser_cur_name_get(parser_data *pd, Evas_Object *entry, void (*cb)(void *data, if (pd->thread) ecore_thread_cancel(pd->thread); cur_name_td *td = calloc(1, sizeof(cur_name_td)); - if (!td) return; + if (!td) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return; + } const char *text = elm_entry_entry_get(entry); if (!text) return; @@ -854,8 +862,20 @@ parser_data * parser_init() { parser_data *pd = calloc(1, sizeof(parser_data)); + if (!pd) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return NULL; + } type_init_td *td = calloc(1, sizeof(type_init_td)); + if (!td) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + free(pd); + return NULL; + } + td->pd = pd; pd->init_thread = ecore_thread_run(type_init_thread_blocking, type_init_thread_end, diff --git a/src/bin/edj_mgr.c b/src/bin/edj_mgr.c index 0d87185..765c4a7 100644 --- a/src/bin/edj_mgr.c +++ b/src/bin/edj_mgr.c @@ -62,6 +62,11 @@ void edj_mgr_init(Evas_Object *parent) { edj_mgr *em = calloc(1, sizeof(edj_mgr)); + if (!em) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return; + } g_em = em; Evas_Object *layout = elm_layout_add(parent); @@ -114,7 +119,11 @@ edj_mgr_view_new(const char *group) edj_mgr *em = g_em; edj_data *edj = calloc(1, sizeof(edj_data)); - if (!edj) return NULL; + if (!edj) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return NULL; + } view_data *vd = view_init(em->layout, group, view_del_cb, edj); if (!vd) diff --git a/src/bin/edj_viewer.c b/src/bin/edj_viewer.c index a57748c..9c608f7 100644 --- a/src/bin/edj_viewer.c +++ b/src/bin/edj_viewer.c @@ -271,6 +271,11 @@ view_init(Evas_Object *parent, const char *group, void (*del_cb)(void *data), void *data) { view_data *vd = calloc(1, sizeof(view_data)); + if (!vd) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return NULL; + } vd->parent = parent; vd->scroller = view_scroller_create(parent); vd->dummy_on = config_dummy_swallow_get(); diff --git a/src/bin/goto.c b/src/bin/goto.c index 9aadc42..7a4cf05 100644 --- a/src/bin/goto.c +++ b/src/bin/goto.c @@ -94,6 +94,11 @@ goto_open(edit_data *ed) search_close(); gd = calloc(1, sizeof(goto_data)); + if (!gd) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return; + } g_gd = gd; //Win diff --git a/src/bin/indent.c b/src/bin/indent.c index 5278993..048f8e7 100644 --- a/src/bin/indent.c +++ b/src/bin/indent.c @@ -11,6 +11,11 @@ indent_data * indent_init(Eina_Strbuf *strbuf) { indent_data *id = malloc(sizeof(indent_data)); + if (!id) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return NULL; + } id->strbuf = strbuf; return id; } diff --git a/src/bin/menu.c b/src/bin/menu.c index 4c65888..948fab2 100644 --- a/src/bin/menu.c +++ b/src/bin/menu.c @@ -1067,6 +1067,11 @@ void menu_init(edit_data *ed) { menu_data *md = calloc(1, sizeof(menu_data)); + if (!md) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return; + } g_md = md; md->ed = ed; diff --git a/src/bin/newfile.c b/src/bin/newfile.c index 0206f40..9e2f3f1 100644 --- a/src/bin/newfile.c +++ b/src/bin/newfile.c @@ -114,6 +114,11 @@ newfile_create(Evas_Object *parent, Evas_Smart_Cb selected_cb, void *data) if (!nd) { nd = calloc(1, sizeof(new_data)); + if (!nd) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return NULL; + } g_nd = nd; } diff --git a/src/bin/panes.c b/src/bin/panes.c index 3d7cd58..e29f124 100644 --- a/src/bin/panes.c +++ b/src/bin/panes.c @@ -142,6 +142,11 @@ Evas_Object * panes_init(Evas_Object *parent) { panes_data *pd = malloc(sizeof(panes_data)); + if (!pd) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return NULL; + } g_pd = pd; //Panes diff --git a/src/bin/search.c b/src/bin/search.c index fc9d67d..32f0d1b 100644 --- a/src/bin/search.c +++ b/src/bin/search.c @@ -314,6 +314,11 @@ search_open(edit_data *ed) goto_close(); sd = calloc(1, sizeof(search_data)); + if (!sd) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return; + } g_sd = sd; //Win diff --git a/src/bin/statusbar.c b/src/bin/statusbar.c index 57bc02a..4343a6f 100644 --- a/src/bin/statusbar.c +++ b/src/bin/statusbar.c @@ -39,6 +39,11 @@ Evas_Object * stats_init(Evas_Object *parent) { stats_data *sd = calloc(1, sizeof(stats_data)); + if (!sd) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return NULL; + } g_sd = sd; Evas_Object *layout = elm_layout_add(parent); diff --git a/src/bin/syntax_color.c b/src/bin/syntax_color.c index 256f017..9cf8f9f 100644 --- a/src/bin/syntax_color.c +++ b/src/bin/syntax_color.c @@ -141,6 +141,11 @@ color_table_init(color_data *cd) } 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); //free(key); @@ -174,6 +179,12 @@ macro_key_push(color_data *cd, char *str, int len) } 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); @@ -201,6 +212,11 @@ color_data * color_init(Eina_Strbuf *strbuf) { color_data *cd = malloc(sizeof(color_data)); + if (!cd) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return NULL; + } cd->strbuf = strbuf; cd->cachebuf = eina_strbuf_new(); cd->thread = ecore_thread_run(init_thread_blocking, NULL, NULL, cd); diff --git a/src/bin/syntax_helper.c b/src/bin/syntax_helper.c index 456ae0f..af6923a 100644 --- a/src/bin/syntax_helper.c +++ b/src/bin/syntax_helper.c @@ -27,6 +27,11 @@ syntax_helper * syntax_init() { syntax_helper *sh = malloc(sizeof(syntax_helper)); + if (!sh) + { + EINA_LOG_ERR("Failed to allocate Memory!"); + return NULL; + } sh->strbuf = eina_strbuf_new(); sh->buf_flush_timer = ecore_timer_add(1800, buf_flush_timer_cb, sh); --
