aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2018-03-15 16:34:08 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2018-03-15 16:34:39 +0100
commitedc73c4c4c9282451149225d4a4f8909f7a41a6a (patch)
tree3764c92b163ef000e3dc1aa427bfdae289d2d241
parenteolian: remove the temps system (diff)
downloadefl-edc73c4c4c9282451149225d4a4f8909f7a41a6a.tar.gz
eolian: make sure dtors are always run correctly
-rw-r--r--src/lib/eolian/eo_lexer.c1
-rw-r--r--src/lib/eolian/eo_parser.c21
2 files changed, 16 insertions, 6 deletions
diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index 9db35a238f..ac64c7b5e5 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -1142,6 +1142,7 @@ eo_lexer_dtor_pop(Eo_Lexer *ls)
{
Eo_Lexer_Dtor *dt = eina_list_data_get(ls->dtors);
ls->dtors = eina_list_remove_list(ls->dtors, ls->dtors);
+ dt->free_cb(dt->data);
free(dt);
}
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 8176e4e413..3b535ddcbc 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -436,8 +436,11 @@ parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
def->base.name = name;
def->type = EOLIAN_TYPEDECL_STRUCT;
def->fields = eina_hash_string_small_new(EINA_FREE_CB(_struct_field_free));
- def->freefunc = freefunc;
- eo_lexer_dtor_pop(ls);
+ if (freefunc)
+ {
+ def->freefunc = eina_stringshare_ref(freefunc);
+ eo_lexer_dtor_pop(ls);
+ }
check_next(ls, '{');
FILL_DOC(ls, def, doc);
while (ls->t.token != '}')
@@ -779,8 +782,11 @@ parse_typedef(Eo_Lexer *ls)
Eina_Strbuf *buf;
eo_lexer_get(ls);
parse_struct_attrs(ls, EINA_FALSE, &has_extern, &freefunc);
- def->freefunc = freefunc;
- eo_lexer_dtor_pop(ls);
+ if (freefunc)
+ {
+ def->freefunc = eina_stringshare_ref(freefunc);
+ eo_lexer_dtor_pop(ls);
+ }
def->type = EOLIAN_TYPEDECL_ALIAS;
def->is_extern = has_extern;
buf = eina_strbuf_new();
@@ -2141,8 +2147,11 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
Eolian_Typedecl *def = eo_lexer_typedecl_new(ls);
def->is_extern = has_extern;
def->type = EOLIAN_TYPEDECL_STRUCT_OPAQUE;
- def->freefunc = freefunc;
- eo_lexer_dtor_pop(ls);
+ if (freefunc)
+ {
+ def->freefunc = eina_stringshare_ref(freefunc);
+ eo_lexer_dtor_pop(ls);
+ }
def->base.name = name;
eo_lexer_get(ls);
FILL_DOC(ls, def, doc);