From: Mengdong Lin Date: Thu, 7 Apr 2016 07:29:01 +0000 (+0800) Subject: topology: Define a free handler for the element X-Git-Tag: v1.1.2~149 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=6b31bf8edb407f4c184576909f40c41bdc8439e4;p=alsa-lib.git topology: Define a free handler for the element This handler is defined for type-specific destruction of an element. Signed-off-by: Mengdong Lin Signed-off-by: Takashi Iwai --- diff --git a/src/topology/elem.c b/src/topology/elem.c index 00f9eeaf..f2afaafd 100644 --- a/src/topology/elem.c +++ b/src/topology/elem.c @@ -83,8 +83,12 @@ void tplg_elem_free(struct tplg_elem *elem) /* free struct snd_tplg_ object, * the union pointers share the same address */ - if (elem->obj) + if (elem->obj) { + if (elem->free) + elem->free(elem->obj); + free(elem->obj); + } free(elem); } diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h index 4915b1a5..7368a867 100644 --- a/src/topology/tplg_local.h +++ b/src/topology/tplg_local.h @@ -127,6 +127,8 @@ struct tplg_elem { */ struct list_head ref_list; struct list_head list; /* list of all elements with same type */ + + void (*free)(void *obj); }; struct map_elem {