From: mengdong.lin@linux.intel.com
To: alsa-devel@alsa-project.org, broonie@kernel.org
Cc: Mengdong Lin <mengdong.lin@linux.intel.com>,
tiwai@suse.de, mengdong.lin@intel.com,
guneshwor.o.singh@intel.com, liam.r.girdwood@intel.com,
hardik.t.shah@intel.com
Subject: [PATCH v2 3/6] topology: Use generic pointer to realloc buffer for private data
Date: Fri, 29 Apr 2016 11:03:22 +0800 [thread overview]
Message-ID: <f3fe69bd44a24732860a7d5743be80ee8564aaae.1461898635.git.mengdong.lin@linux.intel.com> (raw)
In-Reply-To: <cover.1461898635.git.mengdong.lin@linux.intel.com>
From: Mengdong Lin <mengdong.lin@linux.intel.com>
Many element types have private data. So use the generic obj pointer
instead of the type-specific pointer when reallocating the object to
accommodate the private data.
Empty private data will be overlooked.
Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
diff --git a/src/topology/data.c b/src/topology/data.c
index 19c31bf..9f8d5d0 100644
--- a/src/topology/data.c
+++ b/src/topology/data.c
@@ -822,44 +822,36 @@ int tplg_copy_data(struct tplg_elem *elem, struct tplg_elem *ref)
{
struct snd_soc_tplg_private *priv;
int priv_data_size;
+ void *obj;
if (!ref)
return -EINVAL;
tplg_dbg("Data '%s' used by '%s'\n", ref->id, elem->id);
+ if (!ref->data || !ref->data->size) /* overlook empty private data */
+ return 0;
+
priv_data_size = ref->data->size;
+ obj = realloc(elem->obj,
+ elem->size + priv_data_size);
+ if (!obj)
+ return -ENOMEM;
+ elem->obj = obj;
switch (elem->type) {
case SND_TPLG_TYPE_MIXER:
- elem->mixer_ctrl = realloc(elem->mixer_ctrl,
- elem->size + priv_data_size);
- if (!elem->mixer_ctrl)
- return -ENOMEM;
priv = &elem->mixer_ctrl->priv;
break;
case SND_TPLG_TYPE_ENUM:
- elem->enum_ctrl = realloc(elem->enum_ctrl,
- elem->size + priv_data_size);
- if (!elem->enum_ctrl)
- return -ENOMEM;
priv = &elem->enum_ctrl->priv;
break;
case SND_TPLG_TYPE_BYTES:
- elem->bytes_ext = realloc(elem->bytes_ext,
- elem->size + priv_data_size);
- if (!elem->bytes_ext)
- return -ENOMEM;
priv = &elem->bytes_ext->priv;
break;
-
case SND_TPLG_TYPE_DAPM_WIDGET:
- elem->widget = realloc(elem->widget,
- elem->size + priv_data_size);
- if (!elem->widget)
- return -ENOMEM;
priv = &elem->widget->priv;
break;
--
2.5.0
next prev parent reply other threads:[~2016-04-29 3:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-29 3:02 [PATCH v2 0/6] topology: complete PCM parsing and code refactoring mengdong.lin
2016-04-29 3:02 ` [PATCH v2 1/6] topology: Set manifest size for ABI mengdong.lin
2016-04-29 3:03 ` [PATCH v2 2/6] topology: Refactor functions to parse and build streams mengdong.lin
2016-04-29 3:03 ` mengdong.lin [this message]
2016-04-29 3:03 ` [PATCH v2 4/6] topology: Fix pcm ID & name parsing mengdong.lin
2016-04-29 3:03 ` [PATCH v2 5/6] topology: Parse front-end DAI name and ID for the PCM mengdong.lin
2016-04-29 3:03 ` [PATCH v2 6/6] topology: Update PCM configurations in Broadwell text conf file mengdong.lin
2016-05-09 8:34 ` [PATCH v2 0/6] topology: complete PCM parsing and code refactoring Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f3fe69bd44a24732860a7d5743be80ee8564aaae.1461898635.git.mengdong.lin@linux.intel.com \
--to=mengdong.lin@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=guneshwor.o.singh@intel.com \
--cc=hardik.t.shah@intel.com \
--cc=liam.r.girdwood@intel.com \
--cc=mengdong.lin@intel.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).