diff options
author | Tanu Kaskinen <tanuk@iki.fi> | 2009-08-09 07:59:06 +0300 |
---|---|---|
committer | Tanu Kaskinen <tanuk@iki.fi> | 2009-08-09 07:59:06 +0300 |
commit | 1457df40eee692834d1c5faf95ca0057d74f86d1 (patch) | |
tree | 6884f45b91c192b49d5550bfeed011fe099d15b5 /src/pulse/proplist.c | |
parent | 44770c59e92f49288341afe8646d8bc39eb9f589 (diff) |
proplist: New function: pa_proplist_equal()
Diffstat (limited to 'src/pulse/proplist.c')
-rw-r--r-- | src/pulse/proplist.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c index c904f533e..4f0d6a6de 100644 --- a/src/pulse/proplist.c +++ b/src/pulse/proplist.c @@ -680,3 +680,29 @@ int pa_proplist_isempty(pa_proplist *p) { return pa_hashmap_isempty(MAKE_HASHMAP(p)); } + +int pa_proplist_equal(pa_proplist *a, pa_proplist *b) { + const void *key = NULL; + struct property *a_prop = NULL; + struct property *b_prop = NULL; + void *state = NULL; + + pa_assert(a); + pa_assert(b); + + if (pa_proplist_size(a) != pa_proplist_size(b)) + return 0; + + while ((a_prop = pa_hashmap_iterate(MAKE_HASHMAP(a), &state, &key))) { + if (!(b_prop = pa_hashmap_get(MAKE_HASHMAP(b), key))) + return 0; + + if (a_prop->nbytes != b_prop->nbytes) + return 0; + + if (memcmp(a_prop->value, b_prop->value, a_prop->nbytes) != 0) + return 0; + } + + return 1; +} |