diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2013-11-25 22:54:45 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2013-11-25 22:54:45 +0100 |
commit | 30ac2776f48525c53655988d7478915fb9019748 (patch) | |
tree | 972f56f46e7738ca35b3a0f3dd8d64d5a6989810 | |
parent | 0725af34efd1bfd70fcef823681e2e3431707676 (diff) | |
download | eo_tokenizer-30ac2776f48525c53655988d7478915fb9019748.zip eo_tokenizer-30ac2776f48525c53655988d7478915fb9019748.tar.gz |
add _eo_tokenizer_XX_free() functions
-rw-r--r-- | eo_tokenizer.rl | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/eo_tokenizer.rl b/eo_tokenizer.rl index 4d2bb57..aaccfdf 100644 --- a/eo_tokenizer.rl +++ b/eo_tokenizer.rl @@ -298,12 +298,95 @@ eo_tokenizer_dump(Eo_Tokenizer *toknz) } +static void +_eo_tokenizer_ret_free(Eo_Ret_Def *ret) +{ + if (ret->type) eina_stringshare_del(ret->type); + if (ret->comment) eina_stringshare_del(ret->comment); + /* do not free */ +} + +static void +_eo_tokenizer_param_free(Eo_Param_Def *param) +{ + if (param->type) eina_stringshare_del(param->type); + if (param->name) eina_stringshare_del(param->name); + if (param->comment) eina_stringshare_del(param->comment); + free(param); +} + +static void +_eo_tokenizer_property_def_free(Eo_Property_Def *prop) +{ + Eo_Param_Def *param; + + _eo_tokenizer_ret_free(&prop->ret); + + if (prop->name) + eina_stringshare_del(prop->name); + if (prop->comment) + eina_stringshare_del(prop->comment); + + EINA_LIST_FREE(prop->params, param) + _eo_tokenizer_param_free(param); + + free(prop); +} + +static void +_eo_tokenizer_method_def_free(Eo_Method_Def *meth) +{ + Eo_Param_Def *param; + + _eo_tokenizer_ret_free(&meth->ret); + + if (meth->name) + eina_stringshare_del(meth->name); + if (meth->comment) + eina_stringshare_del(meth->comment); + + EINA_LIST_FREE(meth->params, param) + _eo_tokenizer_param_free(param); + + free(meth); +} + +static void +_eo_tokenizer_class_def_free(Eo_Class_Def *kls) +{ + const char *s; + Eina_List *l; + Eo_Property_Def *prop; + Eo_Method_Def *meth; + + if (kls->name) + eina_stringshare_del(kls->name); + if (kls->comment) + eina_stringshare_del(kls->comment); + + EINA_LIST_FOREACH(kls->inherits, l, s) + if (s) eina_stringshare_del(s); + + EINA_LIST_FREE(kls->properties, prop) + _eo_tokenizer_property_def_free(prop); + + EINA_LIST_FREE(kls->methods, meth) + _eo_tokenizer_method_def_free(meth); + + free(kls); +} + void eo_tokenizer_free(Eo_Tokenizer *toknz) { + Eo_Class_Def *kls; + if (toknz->source) eina_stringshare_del(toknz->source); + EINA_LIST_FREE(toknz->classes, kls) + _eo_tokenizer_class_def_free(kls); + free(toknz); } |