From 809e2ed4de22e68fe897465b38e7919b10b378c9 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Thu, 29 Sep 2016 17:19:30 +0200 Subject: [PATCH] eolian gen2: abort on OOM (not much we can do anyway) --- src/bin/eolian2/headers.c | 3 +-- src/bin/eolian2/main.c | 15 +++++++-------- src/bin/eolian2/main.h | 4 ++-- src/bin/eolian2/sources.c | 19 ++++++++----------- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/bin/eolian2/headers.c b/src/bin/eolian2/headers.c index bd593c3..048338c 100644 --- a/src/bin/eolian2/headers.c +++ b/src/bin/eolian2/headers.c @@ -199,8 +199,7 @@ eo_gen_header_gen(const Eolian_Class *cl, Eina_Strbuf *buf, Eina_Bool legacy) return; char *cname = NULL, *cnameu = NULL, *cnamel = NULL; - if (!eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel)) - return; + eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel); /* class definition */ diff --git a/src/bin/eolian2/main.c b/src/bin/eolian2/main.c index b97e64d..a1cda50 100644 --- a/src/bin/eolian2/main.c +++ b/src/bin/eolian2/main.c @@ -1,3 +1,4 @@ +#include #include #include @@ -227,19 +228,19 @@ char *eo_gen_c_full_name_get(const char *nm) return NULL; char *buf = strdup(nm); if (!buf) - return NULL; + abort(); for (char *p = strchr(buf, '.'); p; p = strchr(p, '.')) *p = '_'; return buf; } -Eina_Bool eo_gen_class_names_get(const Eolian_Class *cl, char **cname, - char **cnameu, char **cnamel) +void eo_gen_class_names_get(const Eolian_Class *cl, char **cname, + char **cnameu, char **cnamel) { char *cn = NULL, *cnu = NULL, *cnl = NULL; cn = eo_gen_c_full_name_get(eolian_class_full_name_get(cl)); if (!cn) - return EINA_FALSE; + abort(); if (cname) *cname = cn; @@ -249,7 +250,7 @@ Eina_Bool eo_gen_class_names_get(const Eolian_Class *cl, char **cname, if (!cnu) { free(cn); - return EINA_FALSE; + abort(); } eina_str_toupper(&cnu); *cnameu = cnu; @@ -262,7 +263,7 @@ Eina_Bool eo_gen_class_names_get(const Eolian_Class *cl, char **cname, { free(cn); free(cnu); - return EINA_FALSE; + abort(); } eina_str_tolower(&cnl); *cnamel = cnl; @@ -270,8 +271,6 @@ Eina_Bool eo_gen_class_names_get(const Eolian_Class *cl, char **cname, if (!cname) free(cn); - - return EINA_TRUE; } static Eina_Bool diff --git a/src/bin/eolian2/main.h b/src/bin/eolian2/main.h index fc12597..0dd0b79 100644 --- a/src/bin/eolian2/main.h +++ b/src/bin/eolian2/main.h @@ -36,7 +36,7 @@ extern int _eolian_gen_log_dom; #define CRIT(...) EINA_LOG_DOM_CRIT(_eolian_gen_log_dom, __VA_ARGS__) char *eo_gen_c_full_name_get(const char *nm); -Eina_Bool eo_gen_class_names_get(const Eolian_Class *cl, char **cname, - char **cnameu, char **cnamel); +void eo_gen_class_names_get(const Eolian_Class *cl, char **cname, + char **cnameu, char **cnamel); #endif diff --git a/src/bin/eolian2/sources.c b/src/bin/eolian2/sources.c index 5da860e..91f095b 100644 --- a/src/bin/eolian2/sources.c +++ b/src/bin/eolian2/sources.c @@ -216,10 +216,8 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid, : eina_stringshare_add("void"); char *cname = NULL, *cnameu = NULL, *cnamel = NULL, *ocnamel = NULL; - if (!eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel)) - goto end; - if (!eo_gen_class_names_get(eolian_implement_class_get(impl), NULL, NULL, &ocnamel)) - goto end; + eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel); + eo_gen_class_names_get(eolian_implement_class_get(impl), NULL, NULL, &ocnamel); if (impl_need) { @@ -446,7 +444,6 @@ _gen_func(const Eolian_Class *cl, const Eolian_Function *fid, eina_stringshare_del(eofn); } -end: free(cname); free(cnameu); free(cnamel); @@ -503,8 +500,7 @@ _gen_initializer(const Eolian_Class *cl, Eina_Strbuf *buf) eina_iterator_free(itr); char *cnamel = NULL; - if (!eo_gen_class_names_get(cl, NULL, NULL, &cnamel)) - return EINA_FALSE; + eo_gen_class_names_get(cl, NULL, NULL, &cnamel); eina_strbuf_append(buf, "\nstatic Eina_Bool\n_"); eina_strbuf_append(buf, cnamel); @@ -530,8 +526,8 @@ _gen_initializer(const Eolian_Class *cl, Eina_Strbuf *buf) Eina_Bool found = !!eina_hash_find(_funcs_params_init, &imp); char *ocnamel = NULL; - if ((cl != icl) && !eo_gen_class_names_get(cl, NULL, NULL, &ocnamel)) - return EINA_FALSE; + if (cl != icl) + eo_gen_class_names_get(cl, NULL, NULL, &ocnamel); switch (ftype) { @@ -584,6 +580,8 @@ _gen_initializer(const Eolian_Class *cl, Eina_Strbuf *buf) eina_strbuf_append(buf, "}\n\n"); + free(cnamel); + return EINA_TRUE; } @@ -596,8 +594,7 @@ eo_gen_source_gen(const Eolian_Class *cl, Eina_Strbuf *buf) _funcs_params_init = eina_hash_pointer_new(NULL); char *cname = NULL, *cnameu = NULL, *cnamel = NULL; - if (!eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel)) - return; + eo_gen_class_names_get(cl, &cname, &cnameu, &cnamel); /* event section, they come first */ { -- 2.7.4