From 634a9558e4db46ae3ff2b4615aca30ba1e52b835 Mon Sep 17 00:00:00 2001 From: Pantelis Antoniou Date: Wed, 19 Feb 2020 10:55:29 +0200 Subject: [PATCH] Add a spa_debug_type_find_short_name method Using the short name of a type without the base part is common enough that a common utility method is warranted. Signed-off-by: Pantelis Antoniou --- spa/include/spa/debug/types.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spa/include/spa/debug/types.h b/spa/include/spa/debug/types.h index ae24999d8..85c76fb5c 100644 --- a/spa/include/spa/debug/types.h +++ b/spa/include/spa/debug/types.h @@ -57,6 +57,20 @@ static inline const char *spa_debug_type_find_name(const struct spa_type_info *i return info->name; } +static inline const char *spa_debug_type_find_short_name(const struct spa_type_info *info, uint32_t type) +{ + const char *str, *h; + + str = spa_debug_type_find_name(info, type); + if (!str) + return NULL; + + h = rindex(str, ':'); + if (h) + str = h + 1; + return str; +} + static inline uint32_t spa_debug_type_find_type(const struct spa_type_info *info, const char *name) { if (info == NULL)