mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-16 07:00:00 -05:00
spa: add spa_pod_memcmp
Add a helper to memcmp two pods and use it in some places.
This commit is contained in:
parent
b9a895f825
commit
18ff08243b
3 changed files with 11 additions and 10 deletions
|
|
@ -11,6 +11,7 @@
|
|||
#include <spa/pod/builder.h>
|
||||
#include <spa/pod/iter.h>
|
||||
#include <spa/pod/parser.h>
|
||||
#include <spa/pod/compare.h>
|
||||
#include <spa/param/tag.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -33,8 +34,7 @@ extern "C" {
|
|||
SPA_API_TAG_UTILS int
|
||||
spa_tag_compare(const struct spa_pod *a, const struct spa_pod *b)
|
||||
{
|
||||
return ((a == b) || (a && b && SPA_POD_SIZE(a) == SPA_POD_SIZE(b) &&
|
||||
memcmp(a, b, SPA_POD_SIZE(b)) == 0)) ? 0 : 1;
|
||||
return spa_pod_memcmp(a, b);
|
||||
}
|
||||
|
||||
SPA_API_TAG_UTILS int
|
||||
|
|
|
|||
|
|
@ -80,6 +80,13 @@ SPA_API_POD_COMPARE int spa_pod_compare_value(uint32_t type, const void *r1, con
|
|||
return 0;
|
||||
}
|
||||
|
||||
SPA_API_POD_COMPARE int spa_pod_memcmp(const struct spa_pod *a,
|
||||
const struct spa_pod *b)
|
||||
{
|
||||
return ((a == b) || (a && b && SPA_POD_SIZE(a) == SPA_POD_SIZE(b) &&
|
||||
memcmp(a, b, SPA_POD_SIZE(b)) == 0)) ? 0 : 1;
|
||||
}
|
||||
|
||||
SPA_API_POD_COMPARE int spa_pod_compare(const struct spa_pod *pod1,
|
||||
const struct spa_pod *pod2)
|
||||
{
|
||||
|
|
@ -149,12 +156,8 @@ SPA_API_POD_COMPARE int spa_pod_compare(const struct spa_pod *pod1,
|
|||
break;
|
||||
}
|
||||
case SPA_TYPE_Array:
|
||||
{
|
||||
if (pod1->size != pod2->size)
|
||||
return -EINVAL;
|
||||
res = memcmp(SPA_POD_BODY(pod1), SPA_POD_BODY(pod2), pod2->size);
|
||||
res = spa_pod_memcmp(pod1, pod2);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (pod1->size != pod2->size)
|
||||
return -EINVAL;
|
||||
|
|
|
|||
|
|
@ -339,9 +339,7 @@ SPA_API_POD_FILTER int spa_pod_filter_part(struct spa_pod_builder *b,
|
|||
|
||||
default:
|
||||
if (pf != NULL) {
|
||||
if (pp->size != pf->size)
|
||||
return -EINVAL;
|
||||
if (memcmp(pp, pf, pp->size) != 0)
|
||||
if (spa_pod_memcmp(pp, pf) != 0)
|
||||
return -EINVAL;
|
||||
do_advance = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue