tag: Make tag__delete call the right destructors for non-trivial types

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2009-03-25 13:06:29 -03:00
parent fe88959e80
commit 4024ccee40
2 changed files with 16 additions and 1 deletions

View File

@ -118,7 +118,20 @@ static size_t cacheline_size;
void tag__delete(struct tag *self)
{
assert(list_empty(&self->node));
free(self);
switch (self->tag) {
case DW_TAG_union_type:
type__delete(tag__type(self)); break;
case DW_TAG_class_type:
case DW_TAG_structure_type:
class__delete(tag__class(self)); break;
case DW_TAG_enumeration_type:
enumeration__delete(tag__type(self)); break;
case DW_TAG_subroutine_type:
ftype__delete(tag__ftype(self)); break;
default:
free(self);
}
}
void tag__not_found_die(const char *file, int line, const char *func)

View File

@ -242,6 +242,8 @@ struct tag {
void *priv;
};
void tag__delete(struct tag *self);
static inline int tag__is_enumeration(const struct tag *self)
{
return self->tag == DW_TAG_enumeration_type;