type: improve type check

This commit is contained in:
Wim Taymans 2017-05-17 12:47:33 +02:00
parent 0855ca0050
commit 53dd63eb3a
2 changed files with 6 additions and 6 deletions

View file

@ -45,7 +45,7 @@ typedef uint32_t SpaType;
static inline bool static inline bool
spa_type_is_a (const char *type, const char *parent) spa_type_is_a (const char *type, const char *parent)
{ {
return type != NULL && parent != NULL && strstr (type, parent) == type; return type != NULL && parent != NULL && strncmp (type, parent, strlen (parent)) == 0;
} }
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -270,11 +270,11 @@ main (int argc, char *argv[])
do_static_struct (map); do_static_struct (map);
printf ("%d\n", spa_type_is_a (SPA_TYPE__MediaType, SPA_TYPE_ENUM_BASE)); printf ("media type is enum %d\n", spa_type_is_a (SPA_TYPE__MediaType, SPA_TYPE_ENUM_BASE));
printf ("%d\n", spa_type_is_a (SPA_TYPE__MediaSubtype, SPA_TYPE_ENUM_BASE)); printf ("media sybtype is enum %d\n", spa_type_is_a (SPA_TYPE__MediaSubtype, SPA_TYPE_ENUM_BASE));
printf ("%d\n", spa_type_is_a (SPA_TYPE__Format, SPA_TYPE_ENUM_BASE)); printf ("format is enum %d\n", spa_type_is_a (SPA_TYPE__Format, SPA_TYPE_ENUM_BASE));
printf ("%d\n", spa_type_is_a (SPA_TYPE__Format, SPA_TYPE_POD_BASE)); printf ("format is pod %d\n", spa_type_is_a (SPA_TYPE__Format, SPA_TYPE_POD_BASE));
printf ("%d\n", spa_type_is_a (SPA_TYPE__Format, SPA_TYPE_POD_OBJECT_BASE)); printf ("format is object %d\n", spa_type_is_a (SPA_TYPE__Format, SPA_TYPE_POD_OBJECT_BASE));
return 0; return 0;
} }