From d4fcbaa5d11991fe1079901e13279f02d8f5e579 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 5 Mar 2020 18:17:27 +0100 Subject: [PATCH] debug: make function to get short name --- spa/include/spa/debug/types.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/spa/include/spa/debug/types.h b/spa/include/spa/debug/types.h index 85c76fb5c..12bfb493e 100644 --- a/spa/include/spa/debug/types.h +++ b/spa/include/spa/debug/types.h @@ -50,6 +50,14 @@ static inline const struct spa_type_info *spa_debug_type_find(const struct spa_t return NULL; } +static inline const char *spa_debug_type_short_name(const char *name) +{ + const char *h; + if ((h = rindex(name, ':')) != NULL) + name = h + 1; + return name; +} + static inline const char *spa_debug_type_find_name(const struct spa_type_info *info, uint32_t type) { if ((info = spa_debug_type_find(info, type)) == NULL) @@ -59,16 +67,10 @@ static inline const char *spa_debug_type_find_name(const struct spa_type_info *i 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) + const char *str; + if ((str = spa_debug_type_find_name(info, type)) == NULL) return NULL; - - h = rindex(str, ':'); - if (h) - str = h + 1; - return str; + return spa_debug_type_short_name(str); } static inline uint32_t spa_debug_type_find_type(const struct spa_type_info *info, const char *name)