From mboxrd@z Thu Jan 1 00:00:00 1970 From: mengdong.lin@linux.intel.com Subject: [PATCH 2/7] topology: Define a free handler for the element Date: Thu, 24 Mar 2016 11:06:40 +0800 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by alsa0.perex.cz (Postfix) with ESMTP id A631E261ABB for ; Thu, 24 Mar 2016 04:04:41 +0100 (CET) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: alsa-devel@alsa-project.org, broonie@kernel.org Cc: Mengdong Lin , tiwai@suse.de, mengdong.lin@intel.com, vinod.koul@intel.com, rakesh.a.ughreja@intel.com, liam.r.girdwood@intel.com, hardik.t.shah@intel.com, subhransu.s.prusty@intel.com List-Id: alsa-devel@alsa-project.org From: Mengdong Lin This handler is defined for type-specific destruction of an element. Signed-off-by: Mengdong Lin diff --git a/src/topology/elem.c b/src/topology/elem.c index 00f9eea..f2afaaf 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 4915b1a..7368a86 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 { -- 2.5.0