From 8944cc44c1e21496411ec8923968dab8542ae401 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Tue, 15 Dec 2015 16:01:02 +0000 Subject: [PATCH] eolian: add typedecl delete func and init hashes correctly --- src/lib/eolian/Eolian.h | 6 ++++++ src/lib/eolian/database_type.c | 21 +++++++++++++++++++-- src/lib/eolian/eolian_database.c | 3 +++ src/lib/eolian/eolian_database.h | 3 +++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h index 0acdf81..f88dd45 100644 --- a/src/lib/eolian/Eolian.h +++ b/src/lib/eolian/Eolian.h @@ -105,6 +105,12 @@ typedef struct _Eolian_Function Eolian_Function; */ typedef struct _Eolian_Type Eolian_Type; +/* Type declaration. + * + * @ingroup Eolian + */ +typedef struct _Eolian_Typedecl Eolian_Typedecl; + /* Class function parameter information * * @ingroup Eolian diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c index 787cc3d..e809858 100644 --- a/src/lib/eolian/database_type.c +++ b/src/lib/eolian/database_type.c @@ -14,8 +14,7 @@ database_type_del(Eolian_Type *tp) if (tp->base.file) eina_stringshare_del(tp->base.file); if (tp->subtypes) EINA_LIST_FREE(tp->subtypes, stp) database_type_del(stp); - if (tp->base_type) - database_type_del(tp->base_type); + database_type_del(tp->base_type); if (tp->name) eina_stringshare_del(tp->name); if (tp->full_name) eina_stringshare_del(tp->full_name); if (tp->fields) eina_hash_free(tp->fields); @@ -29,6 +28,24 @@ database_type_del(Eolian_Type *tp) } void +database_typedecl_del(Eolian_Typedecl *tp) +{ + if (!tp) return; + const char *sp; + if (tp->base.file) eina_stringshare_del(tp->base.file); + database_type_del(tp->base_type); + if (tp->name) eina_stringshare_del(tp->name); + if (tp->full_name) eina_stringshare_del(tp->full_name); + if (tp->fields) eina_hash_free(tp->fields); + if (tp->field_list) eina_list_free(tp->field_list); + if (tp->namespaces) EINA_LIST_FREE(tp->namespaces, sp) + eina_stringshare_del(sp); + if (tp->legacy) eina_stringshare_del(tp->legacy); + database_doc_del(tp->doc); + free(tp); +} + +void database_typedef_del(Eolian_Type *tp) { if (!tp) return; diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c index b6da857..c2caac4 100644 --- a/src/lib/eolian/eolian_database.c +++ b/src/lib/eolian/eolian_database.c @@ -47,8 +47,11 @@ database_init() eina_init(); _classes = eina_hash_stringshared_new(EINA_FREE_CB(database_class_del)); _aliases = eina_hash_stringshared_new(EINA_FREE_CB(database_typedef_del)); + _aliasesd = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del)); _structs = eina_hash_stringshared_new(EINA_FREE_CB(database_type_del)); + _structsd = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del)); _enums = eina_hash_stringshared_new(EINA_FREE_CB(database_type_del)); + _enumsd = eina_hash_stringshared_new(EINA_FREE_CB(database_typedecl_del)); _globals = eina_hash_stringshared_new(EINA_FREE_CB(database_var_del)); _constants = eina_hash_stringshared_new(EINA_FREE_CB(database_var_del)); _classesf = eina_hash_stringshared_new(NULL); diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h index f06949d..ac06cc2 100644 --- a/src/lib/eolian/eolian_database.h +++ b/src/lib/eolian/eolian_database.h @@ -187,6 +187,7 @@ struct _Eolian_Typedecl { Eolian_Object base; Eolian_Typedecl_Type type; + Eolian_Type *base_type; Eina_Stringshare *name; Eina_Stringshare *full_name; Eina_List *namespaces; @@ -304,6 +305,8 @@ void database_enum_add(Eolian_Type *tp); void database_type_del(Eolian_Type *tp); void database_typedef_del(Eolian_Type *tp); +void database_typedecl_del(Eolian_Typedecl *tp); + void database_type_print(Eolian_Type *type); void database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name); -- 2.7.4