From 3050af4b90ff6ecf41c931164ab3010b5d248a91 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 13 May 2021 10:59:43 +0200 Subject: [PATCH] conf: add snd_config_is_empty() function Signed-off-by: Jaroslav Kysela --- include/conf.h | 1 + src/conf.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/conf.h b/include/conf.h index e729fb05..5c70ebcc 100644 --- a/include/conf.h +++ b/include/conf.h @@ -141,6 +141,7 @@ int snd_config_imake_pointer(snd_config_t **config, const char *key, const void snd_config_type_t snd_config_get_type(const snd_config_t *config); int snd_config_is_array(const snd_config_t *config); +int snd_config_is_empty(const snd_config_t *config); int snd_config_set_id(snd_config_t *config, const char *id); int snd_config_set_integer(snd_config_t *config, long value); diff --git a/src/conf.c b/src/conf.c index 72422f12..7ebf7577 100644 --- a/src/conf.c +++ b/src/conf.c @@ -1832,6 +1832,19 @@ int snd_config_is_array(const snd_config_t *config) return 1; } +/** + * \brief Returns if the compound has no fields (is empty). + * \param config Handle to the configuration node. + * \return A positive value when true, zero when false, otherwise a negative error code. + */ +int snd_config_is_empty(const snd_config_t *config) +{ + assert(config); + if (config->type != SND_CONFIG_TYPE_COMPOUND) + return -EINVAL; + return list_empty(&config->u.compound.fields); +} + /** * \brief Returns the id of a configuration node. * \param[in] config Handle to the configuration node. -- 2.47.1