summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-11-01 03:50:14 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2018-11-01 03:50:14 +0200
commit7b105f7622bf9df1898d8d2005ea3d3ee4f7038c (patch)
treebbfd0c2707f9001f2731ea5024ea7b0316a844eb
parent7206b492d8f026daabcf168082fcd55480b3d652 (diff)
make the malloc functions less verbose
-rw-r--r--src/mixer.c5
-rw-r--r--src/pcm.c6
2 files changed, 3 insertions, 8 deletions
diff --git a/src/mixer.c b/src/mixer.c
index 5b07f15..56e2293 100644
--- a/src/mixer.c
+++ b/src/mixer.c
@@ -244,10 +244,7 @@ struct _snd_mixer_selem_id {
int
snd_mixer_selem_id_malloc(snd_mixer_selem_id_t **ptr)
{
- if (!(*ptr = calloc(1, sizeof(**ptr))))
- return -1;
-
- return 0;
+ return ((*ptr = calloc(1, sizeof(**ptr))) ? 0 : -1);
}
void
diff --git a/src/pcm.c b/src/pcm.c
index 36a9bc8..8a5e38a 100644
--- a/src/pcm.c
+++ b/src/pcm.c
@@ -600,8 +600,7 @@ int
snd_pcm_hw_params_malloc(snd_pcm_hw_params_t **ptr)
{
// OpenAL-soft uses this :(
- *ptr = calloc(1, sizeof(**ptr));
- return (*ptr ? 0 : -1);
+ return ((*ptr = calloc(1, sizeof(**ptr))) ? 0 : -1);
}
void
@@ -920,8 +919,7 @@ int
snd_pcm_sw_params_malloc(snd_pcm_sw_params_t **ptr)
{
// OpenAL-soft uses this :(
- *ptr = calloc(1, sizeof(**ptr));
- return (*ptr ? 0 : -1);
+ return ((*ptr = calloc(1, sizeof(**ptr))) ? 0 : -1);
}
void