Constification patch set ** 1 of 2 **
Collection of 16 patches constifying pointers in various parts of the
API.
This collection of patches has interdependencies, they must be applied
in (roughly) the given order.
These start off with constifying some core hashmap functions, which
then allows various proplist related functions to be changed. A couple
of tagstruct functions are in there, and finally a couple of
context+proplist related functions.
I have not been in a position to try and compile these changes. I have
identified one possible problem - the hashmap.c BY_HASH macro - I'm not
certain offhand if a const version will be required or if the compiler
will be happy casting as is. Otherwise I'm fairly certain there are no
(obvious) issues.
From ae549e3b6a02673cb128fb8a07c6d8f74c2b79ee Mon Sep 17 00:00:00 2001
From: Lyndon Brown <[email protected]>
Date: Sun, 27 May 2018 02:27:43 +0100
Subject: core/hashmap: constify hashmap ptr for various functions
diff --git a/src/pulsecore/hashmap.c b/src/pulsecore/hashmap.c
index 2385c55c..6477783e 100644
--- a/src/pulsecore/hashmap.c
+++ b/src/pulsecore/hashmap.c
@@ -231,7 +231,7 @@ void pa_hashmap_remove_all(pa_hashmap *h) {
}
}
-void *pa_hashmap_iterate(pa_hashmap *h, void **state, const void **key) {
+void *pa_hashmap_iterate(const pa_hashmap *h, void **state, const void **key) {
struct hashmap_entry *e;
pa_assert(h);
@@ -264,7 +264,7 @@ at_end:
return NULL;
}
-void *pa_hashmap_iterate_backwards(pa_hashmap *h, void **state, const void **key) {
+void *pa_hashmap_iterate_backwards(const pa_hashmap *h, void **state, const void **key) {
struct hashmap_entry *e;
pa_assert(h);
@@ -297,7 +297,7 @@ at_beginning:
return NULL;
}
-void* pa_hashmap_first(pa_hashmap *h) {
+void* pa_hashmap_first(const pa_hashmap *h) {
pa_assert(h);
if (!h->iterate_list_head)
@@ -306,7 +306,7 @@ void* pa_hashmap_first(pa_hashmap *h) {
return h->iterate_list_head->value;
}
-void* pa_hashmap_last(pa_hashmap *h) {
+void* pa_hashmap_last(const pa_hashmap *h) {
pa_assert(h);
if (!h->iterate_list_tail)
@@ -329,13 +329,13 @@ void* pa_hashmap_steal_first(pa_hashmap *h) {
return data;
}
-unsigned pa_hashmap_size(pa_hashmap *h) {
+unsigned pa_hashmap_size(const pa_hashmap *h) {
pa_assert(h);
return h->n_entries;
}
-bool pa_hashmap_isempty(pa_hashmap *h) {
+bool pa_hashmap_isempty(const pa_hashmap *h) {
pa_assert(h);
return h->n_entries == 0;
diff --git a/src/pulsecore/hashmap.h b/src/pulsecore/hashmap.h
index b1027e75..ea883765 100644
--- a/src/pulsecore/hashmap.h
+++ b/src/pulsecore/hashmap.h
@@ -61,10 +61,10 @@ int pa_hashmap_remove_and_free(pa_hashmap *h, const void *key);
void pa_hashmap_remove_all(pa_hashmap *h);
/* Return the current number of entries of the hashmap */
-unsigned pa_hashmap_size(pa_hashmap *h);
+unsigned pa_hashmap_size(const pa_hashmap *h);
/* Return true if the hashmap is empty */
-bool pa_hashmap_isempty(pa_hashmap *h);
+bool pa_hashmap_isempty(const pa_hashmap *h);
/* May be used to iterate through the hashmap. Initially the opaque
pointer *state has to be set to NULL. The hashmap may not be
@@ -72,19 +72,19 @@ bool pa_hashmap_isempty(pa_hashmap *h);
via pa_hashmap_remove(). The key of the entry is returned in *key,
if key is non-NULL. After the last entry in the hashmap NULL is
returned. */
-void *pa_hashmap_iterate(pa_hashmap *h, void **state, const void**key);
+void *pa_hashmap_iterate(const pa_hashmap *h, void **state, const void**key);
/* Same as pa_hashmap_iterate() but goes backwards */
-void *pa_hashmap_iterate_backwards(pa_hashmap *h, void **state, const void**key);
+void *pa_hashmap_iterate_backwards(const pa_hashmap *h, void **state, const void**key);
/* Remove the oldest entry in the hashmap and return it */
void *pa_hashmap_steal_first(pa_hashmap *h);
/* Return the oldest entry in the hashmap */
-void* pa_hashmap_first(pa_hashmap *h);
+void* pa_hashmap_first(const pa_hashmap *h);
/* Return the newest entry in the hashmap */
-void* pa_hashmap_last(pa_hashmap *h);
+void* pa_hashmap_last(const pa_hashmap *h);
/* A macro to ease iteration through all entries */
#define PA_HASHMAP_FOREACH(e, h, state) \
From b87af9de83f95eb2271112b36ebc32da44c64d12 Mon Sep 17 00:00:00 2001
From: Lyndon Brown <[email protected]>
Date: Sun, 27 May 2018 02:56:11 +0100
Subject: core/hashmap: constify pointer of private hash_scan function
paves the way for doing the same for pa_hashmap_get and users of it
diff --git a/src/pulsecore/hashmap.c b/src/pulsecore/hashmap.c
index 6477783e..c03af3bc 100644
--- a/src/pulsecore/hashmap.c
+++ b/src/pulsecore/hashmap.c
@@ -119,7 +119,7 @@ void pa_hashmap_free(pa_hashmap *h) {
pa_xfree(h);
}
-static struct hashmap_entry *hash_scan(pa_hashmap *h, unsigned hash, const void *key) {
+static struct hashmap_entry *hash_scan(const pa_hashmap *h, unsigned hash, const void *key) {
struct hashmap_entry *e;
pa_assert(h);
pa_assert(hash < NBUCKETS);
From ddb7776dbbc40b2e9e1f6a5045ed3e72ce8326f6 Mon Sep 17 00:00:00 2001
From: Lyndon Brown <[email protected]>
Date: Sun, 27 May 2018 02:57:12 +0100
Subject: core/hashmap: constify pointer of pa_hashmap_get
relies upon the same having just been done for the private hash_scan
function
diff --git a/src/pulsecore/hashmap.c b/src/pulsecore/hashmap.c
index c03af3bc..c2fc3f5e 100644
--- a/src/pulsecore/hashmap.c
+++ b/src/pulsecore/hashmap.c
@@ -173,7 +173,7 @@ int pa_hashmap_put(pa_hashmap *h, void *key, void *value) {
return 0;
}
-void* pa_hashmap_get(pa_hashmap *h, const void *key) {
+void* pa_hashmap_get(const pa_hashmap *h, const void *key) {
unsigned hash;
struct hashmap_entry *e;
diff --git a/src/pulsecore/hashmap.h b/src/pulsecore/hashmap.h
index ea883765..c18a564f 100644
--- a/src/pulsecore/hashmap.h
+++ b/src/pulsecore/hashmap.h
@@ -45,7 +45,7 @@ void pa_hashmap_free(pa_hashmap*);
int pa_hashmap_put(pa_hashmap *h, void *key, void *value);
/* Return an entry from the hashmap */
-void* pa_hashmap_get(pa_hashmap *h, const void *key);
+void* pa_hashmap_get(const pa_hashmap *h, const void *key);
/* Returns the data of the entry while removing */
void* pa_hashmap_remove(pa_hashmap *h, const void *key);
From 4169dc6a2fa2821f9193a7a07ea9ff61df9dd24b Mon Sep 17 00:00:00 2001
From: Lyndon Brown <[email protected]>
Date: Sun, 27 May 2018 02:41:54 +0100
Subject: proplist: add and use const version of MAKE_HASHMAP macro
diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index d8c64044..328d3ad2 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -40,6 +40,7 @@ struct property {
};
#define MAKE_HASHMAP(p) ((pa_hashmap*) (p))
+#define MAKE_HASHMAP_CONST(p) ((const pa_hashmap*) (p))
#define MAKE_PROPLIST(p) ((pa_proplist*) (p))
int pa_proplist_key_valid(const char *key) {
@@ -83,7 +84,7 @@ int pa_proplist_sets(pa_proplist *p, const char *key, const char *value) {
if (!pa_proplist_key_valid(key) || !pa_utf8_valid(value))
return -1;
- if (!(prop = pa_hashmap_get(MAKE_HASHMAP(p), key))) {
+ if (!(prop = pa_hashmap_get(MAKE_HASHMAP_CONST(p), key))) {
prop = pa_xnew(struct property, 1);
prop->key = pa_xstrdup(key);
add = true;
@@ -118,7 +119,7 @@ static int proplist_setn(pa_proplist *p, const char *key, size_t key_length, con
return -1;
}
- if (!(prop = pa_hashmap_get(MAKE_HASHMAP(p), k))) {
+ if (!(prop = pa_hashmap_get(MAKE_HASHMAP_CONST(p), k))) {
prop = pa_xnew(struct property, 1);
prop->key = k;
add = true;
@@ -181,7 +182,7 @@ static int proplist_sethex(pa_proplist *p, const char *key, size_t key_length, c
pa_xfree(v);
- if (!(prop = pa_hashmap_get(MAKE_HASHMAP(p), k))) {
+ if (!(prop = pa_hashmap_get(MAKE_HASHMAP_CONST(p), k))) {
prop = pa_xnew(struct property, 1);
prop->key = k;
add = true;
@@ -221,7 +222,7 @@ int pa_proplist_setf(pa_proplist *p, const char *key, const char *format, ...) {
if (!pa_utf8_valid(v))
goto fail;
- if (!(prop = pa_hashmap_get(MAKE_HASHMAP(p), key))) {
+ if (!(prop = pa_hashmap_get(MAKE_HASHMAP_CONST(p), key))) {
prop = pa_xnew(struct property, 1);
prop->key = pa_xstrdup(key);
add = true;
@@ -252,7 +253,7 @@ int pa_proplist_set(pa_proplist *p, const char *key, const void *data, size_t nb
if (!pa_proplist_key_valid(key))
return -1;
- if (!(prop = pa_hashmap_get(MAKE_HASHMAP(p), key))) {
+ if (!(prop = pa_hashmap_get(MAKE_HASHMAP_CONST(p), key))) {
prop = pa_xnew(struct property, 1);
prop->key = pa_xstrdup(key);
add = true;
@@ -280,7 +281,7 @@ const char *pa_proplist_gets(pa_proplist *p, const char *key) {
if (!pa_proplist_key_valid(key))
return NULL;
- if (!(prop = pa_hashmap_get(MAKE_HASHMAP(p), key)))
+ if (!(prop = pa_hashmap_get(MAKE_HASHMAP_CONST(p), key)))
return NULL;
if (prop->nbytes <= 0)
@@ -309,7 +310,7 @@ int pa_proplist_get(pa_proplist *p, const char *key, const void **data, size_t *
if (!pa_proplist_key_valid(key))
return -1;
- if (!(prop = pa_hashmap_get(MAKE_HASHMAP(p), key)))
+ if (!(prop = pa_hashmap_get(MAKE_HASHMAP_CONST(p), key)))
return -1;
*data = prop->value;
@@ -329,9 +330,7 @@ void pa_proplist_update(pa_proplist *p, pa_update_mode_t mode, const pa_proplist
if (mode == PA_UPDATE_SET)
pa_proplist_clear(p);
- /* MAKE_HASHMAP turns the const pointer into a non-const pointer, but
- * that's ok, because we don't modify the hashmap contents. */
- while ((prop = pa_hashmap_iterate(MAKE_HASHMAP(other), &state, NULL))) {
+ while ((prop = pa_hashmap_iterate(MAKE_HASHMAP_CONST(other), &state, NULL))) {
if (mode == PA_UPDATE_MERGE && pa_proplist_contains(p, prop->key))
continue;
@@ -374,7 +373,7 @@ int pa_proplist_unset_many(pa_proplist *p, const char * const keys[]) {
const char *pa_proplist_iterate(pa_proplist *p, void **state) {
struct property *prop;
- if (!(prop = pa_hashmap_iterate(MAKE_HASHMAP(p), state, NULL)))
+ if (!(prop = pa_hashmap_iterate(MAKE_HASHMAP_CONST(p), state, NULL)))
return NULL;
return prop->key;
@@ -640,7 +639,7 @@ int pa_proplist_contains(pa_proplist *p, const char *key) {
if (!pa_proplist_key_valid(key))
return -1;
- if (!(pa_hashmap_get(MAKE_HASHMAP(p), key)))
+ if (!(pa_hashmap_get(MAKE_HASHMAP_CONST(p), key)))
return 0;
return 1;
@@ -666,13 +665,13 @@ pa_proplist* pa_proplist_copy(const pa_proplist *p) {
unsigned pa_proplist_size(pa_proplist *p) {
pa_assert(p);
- return pa_hashmap_size(MAKE_HASHMAP(p));
+ return pa_hashmap_size(MAKE_HASHMAP_CONST(p));
}
int pa_proplist_isempty(pa_proplist *p) {
pa_assert(p);
- return pa_hashmap_isempty(MAKE_HASHMAP(p));
+ return pa_hashmap_isempty(MAKE_HASHMAP_CONST(p));
}
int pa_proplist_equal(pa_proplist *a, pa_proplist *b) {
@@ -690,8 +689,8 @@ int pa_proplist_equal(pa_proplist *a, pa_proplist *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)))
+ while ((a_prop = pa_hashmap_iterate(MAKE_HASHMAP_CONST(a), &state, &key))) {
+ if (!(b_prop = pa_hashmap_get(MAKE_HASHMAP_CONST(b), key)))
return 0;
if (a_prop->nbytes != b_prop->nbytes)
From 721730423c3d98da8ab3e2520bc705fa24adb313 Mon Sep 17 00:00:00 2001
From: Lyndon Brown <[email protected]>
Date: Sun, 27 May 2018 02:45:47 +0100
Subject: proplist: pa_proplist_iterate: constify proplist pointer
diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index 328d3ad2..37877b4e 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -370,7 +370,7 @@ int pa_proplist_unset_many(pa_proplist *p, const char * const keys[]) {
return n;
}
-const char *pa_proplist_iterate(pa_proplist *p, void **state) {
+const char *pa_proplist_iterate(const pa_proplist *p, void **state) {
struct property *prop;
if (!(prop = pa_hashmap_iterate(MAKE_HASHMAP_CONST(p), state, NULL)))
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index cec3b357..14139a7e 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -368,7 +368,7 @@ int pa_proplist_unset_many(pa_proplist *p, const char * const keys[]);
* current entry. On each invocation this function will return the
* key string for the next entry. The keys in the property list do not
* have any particular order. \since 0.9.11 */
-const char *pa_proplist_iterate(pa_proplist *p, void **state);
+const char *pa_proplist_iterate(const pa_proplist *p, void **state);
/** Format the property list nicely as a human readable string. This
* works very much like pa_proplist_to_string_sep() and uses a newline
From 2eac9ed3dc498ae2c95736c78ae12380953090db Mon Sep 17 00:00:00 2001
From: Lyndon Brown <[email protected]>
Date: Sun, 27 May 2018 02:59:12 +0100
Subject: proplist: pa_proplist_get: constify proplist pointer
diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index 37877b4e..0da127ef 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -299,7 +299,7 @@ const char *pa_proplist_gets(pa_proplist *p, const char *key) {
return (char*) prop->value;
}
-int pa_proplist_get(pa_proplist *p, const char *key, const void **data, size_t *nbytes) {
+int pa_proplist_get(const pa_proplist *p, const char *key, const void **data, size_t *nbytes) {
struct property *prop;
pa_assert(p);
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index 14139a7e..68900183 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -318,7 +318,7 @@ const char *pa_proplist_gets(pa_proplist *p, const char *key);
* point to an internally allocated buffer. The caller should make a
* copy of the data before the property list is accessed again.
* Returns zero on success, negative on error. \since 0.9.11 */
-int pa_proplist_get(pa_proplist *p, const char *key, const void **data, size_t *nbytes);
+int pa_proplist_get(const pa_proplist *p, const char *key, const void **data, size_t *nbytes);
/** Update mode enum for pa_proplist_update(). \since 0.9.11 */
typedef enum pa_update_mode {
From 3ba7d1126d4a593a99e28ee4bb06a53272b051f2 Mon Sep 17 00:00:00 2001
From: Lyndon Brown <[email protected]>
Date: Sun, 27 May 2018 04:10:53 +0100
Subject: proplist: pa_proplist_gets: constify proplist pointer
diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index 0da127ef..f9aaea5b 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -272,7 +272,7 @@ int pa_proplist_set(pa_proplist *p, const char *key, const void *data, size_t nb
return 0;
}
-const char *pa_proplist_gets(pa_proplist *p, const char *key) {
+const char *pa_proplist_gets(const pa_proplist *p, const char *key) {
struct property *prop;
pa_assert(p);
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index 68900183..9e0f706e 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -311,7 +311,7 @@ int pa_proplist_set(pa_proplist *p, const char *key, const void *data, size_t nb
* the data is not valid UTF-8. Will return a NUL-terminated string in
* an internally allocated buffer. The caller should make a copy of
* the data before accessing the property list again. \since 0.9.11 */
-const char *pa_proplist_gets(pa_proplist *p, const char *key);
+const char *pa_proplist_gets(const pa_proplist *p, const char *key);
/** Store the value for the specified key in \a data. Will store a
* NUL-terminated string for string entries. The \a data pointer returned will
From 03ff34da8f06900752bd2a417a7a12fd59dc1c88 Mon Sep 17 00:00:00 2001
From: Lyndon Brown <[email protected]>
Date: Sun, 27 May 2018 03:01:14 +0100
Subject: core/tagstruct: pa_tagstruct_put_proplist: constify proplist pointer
diff --git a/src/pulsecore/tagstruct.c b/src/pulsecore/tagstruct.c
index 8a29957b..50168717 100644
--- a/src/pulsecore/tagstruct.c
+++ b/src/pulsecore/tagstruct.c
@@ -310,7 +310,7 @@ void pa_tagstruct_put_volume(pa_tagstruct *t, pa_volume_t vol) {
write_u32(t, vol);
}
-void pa_tagstruct_put_proplist(pa_tagstruct *t, pa_proplist *p) {
+void pa_tagstruct_put_proplist(pa_tagstruct *t, const pa_proplist *p) {
void *state = NULL;
pa_assert(t);
pa_assert(p);
diff --git a/src/pulsecore/tagstruct.h b/src/pulsecore/tagstruct.h
index 348c65d2..9236490a 100644
--- a/src/pulsecore/tagstruct.h
+++ b/src/pulsecore/tagstruct.h
@@ -81,7 +81,7 @@ void pa_tagstruct_put_timeval(pa_tagstruct*t, const struct timeval *tv);
void pa_tagstruct_put_usec(pa_tagstruct*t, pa_usec_t u);
void pa_tagstruct_put_channel_map(pa_tagstruct *t, const pa_channel_map *map);
void pa_tagstruct_put_cvolume(pa_tagstruct *t, const pa_cvolume *cvolume);
-void pa_tagstruct_put_proplist(pa_tagstruct *t, pa_proplist *p);
+void pa_tagstruct_put_proplist(pa_tagstruct *t, const pa_proplist *p);
void pa_tagstruct_put_volume(pa_tagstruct *t, pa_volume_t volume);
void pa_tagstruct_put_format_info(pa_tagstruct *t, pa_format_info *f);
From 58d6a64cf97333b0e5de8fa9ab19560e0562e055 Mon Sep 17 00:00:00 2001
From: Lyndon Brown <[email protected]>
Date: Sun, 27 May 2018 03:02:30 +0100
Subject: core/tagstruct: pa_tagstruct_put_format_info: constify format pointer
diff --git a/src/pulsecore/tagstruct.c b/src/pulsecore/tagstruct.c
index 50168717..6e9c7d15 100644
--- a/src/pulsecore/tagstruct.c
+++ b/src/pulsecore/tagstruct.c
@@ -334,7 +334,7 @@ void pa_tagstruct_put_proplist(pa_tagstruct *t, const pa_proplist *p) {
pa_tagstruct_puts(t, NULL);
}
-void pa_tagstruct_put_format_info(pa_tagstruct *t, pa_format_info *f) {
+void pa_tagstruct_put_format_info(pa_tagstruct *t, const pa_format_info *f) {
pa_assert(t);
pa_assert(f);
diff --git a/src/pulsecore/tagstruct.h b/src/pulsecore/tagstruct.h
index 9236490a..dcb51cbf 100644
--- a/src/pulsecore/tagstruct.h
+++ b/src/pulsecore/tagstruct.h
@@ -83,7 +83,7 @@ void pa_tagstruct_put_channel_map(pa_tagstruct *t, const pa_channel_map *map);
void pa_tagstruct_put_cvolume(pa_tagstruct *t, const pa_cvolume *cvolume);
void pa_tagstruct_put_proplist(pa_tagstruct *t, const pa_proplist *p);
void pa_tagstruct_put_volume(pa_tagstruct *t, pa_volume_t volume);
-void pa_tagstruct_put_format_info(pa_tagstruct *t, pa_format_info *f);
+void pa_tagstruct_put_format_info(pa_tagstruct *t, const pa_format_info *f);
int pa_tagstruct_get(pa_tagstruct *t, ...);
From 4c897a8f8fc6f699f3297071b7b36235d7e486b7 Mon Sep 17 00:00:00 2001
From: Lyndon Brown <[email protected]>
Date: Sun, 27 May 2018 03:04:43 +0100
Subject: context: pa_context_proplist_update: constify proplist pointer
diff --git a/src/pulse/context.c b/src/pulse/context.c
index 6adfc5a9..e7695009 100644
--- a/src/pulse/context.c
+++ b/src/pulse/context.c
@@ -1369,7 +1369,7 @@ uint32_t pa_context_get_index(pa_context *c) {
return c->client_index;
}
-pa_operation *pa_context_proplist_update(pa_context *c, pa_update_mode_t mode, pa_proplist *p, pa_context_success_cb_t cb, void *userdata) {
+pa_operation *pa_context_proplist_update(pa_context *c, pa_update_mode_t mode, const pa_proplist *p, pa_context_success_cb_t cb, void *userdata) {
pa_operation *o;
pa_tagstruct *t;
uint32_t tag;
diff --git a/src/pulse/context.h b/src/pulse/context.h
index 9b96f8ce..2cb0776e 100644
--- a/src/pulse/context.h
+++ b/src/pulse/context.h
@@ -247,7 +247,7 @@ uint32_t pa_context_get_server_protocol_version(pa_context *c);
* initially via pa_context_new_with_proplist() as possible instead a
* posteriori with this function, since that information may then be
* used to route streams of the client to the right device. \since 0.9.11 */
-pa_operation *pa_context_proplist_update(pa_context *c, pa_update_mode_t mode, pa_proplist *p, pa_context_success_cb_t cb, void *userdata);
+pa_operation *pa_context_proplist_update(pa_context *c, pa_update_mode_t mode, const pa_proplist *p, pa_context_success_cb_t cb, void *userdata);
/** Update the property list of the client, remove entries. \since 0.9.11 */
pa_operation *pa_context_proplist_remove(pa_context *c, const char *const keys[], pa_context_success_cb_t cb, void *userdata);
From f49e93f176582c975adc33f38943d172d43471e1 Mon Sep 17 00:00:00 2001
From: Lyndon Brown <[email protected]>
Date: Sun, 27 May 2018 04:31:49 +0100
Subject: proplist: pa_proplist_to_string[_sep]: constify proplist pointer
diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index f9aaea5b..75500246 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -379,7 +379,7 @@ const char *pa_proplist_iterate(const pa_proplist *p, void **state) {
return prop->key;
}
-char *pa_proplist_to_string_sep(pa_proplist *p, const char *sep) {
+char *pa_proplist_to_string_sep(const pa_proplist *p, const char *sep) {
const char *key;
void *state = NULL;
pa_strbuf *buf;
@@ -437,7 +437,7 @@ char *pa_proplist_to_string_sep(pa_proplist *p, const char *sep) {
return pa_strbuf_to_string_free(buf);
}
-char *pa_proplist_to_string(pa_proplist *p) {
+char *pa_proplist_to_string(const pa_proplist *p) {
char *s, *t;
s = pa_proplist_to_string_sep(p, "\n");
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index 9e0f706e..f7a42826 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -374,12 +374,12 @@ const char *pa_proplist_iterate(const pa_proplist *p, void **state);
* works very much like pa_proplist_to_string_sep() and uses a newline
* as separator and appends one final one. Call pa_xfree() on the
* result. \since 0.9.11 */
-char *pa_proplist_to_string(pa_proplist *p);
+char *pa_proplist_to_string(const pa_proplist *p);
/** Format the property list nicely as a human readable string and
* choose the separator. Call pa_xfree() on the result. \since
* 0.9.15 */
-char *pa_proplist_to_string_sep(pa_proplist *p, const char *sep);
+char *pa_proplist_to_string_sep(const pa_proplist *p, const char *sep);
/** Allocate a new property list and assign key/value from a human
* readable string. \since 0.9.15 */
From 737914a9a266a03bfe0883627a21464d49c75351 Mon Sep 17 00:00:00 2001
From: Lyndon Brown <[email protected]>
Date: Sun, 27 May 2018 04:35:33 +0100
Subject: proplist: pa_proplist_contains: constify proplist pointer
diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index 75500246..4ad092d6 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -632,7 +632,7 @@ fail:
return NULL;
}
-int pa_proplist_contains(pa_proplist *p, const char *key) {
+int pa_proplist_contains(const pa_proplist *p, const char *key) {
pa_assert(p);
pa_assert(key);
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index f7a42826..c148c793 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -387,7 +387,7 @@ pa_proplist *pa_proplist_from_string(const char *str);
/** Returns 1 if an entry for the specified key exists in the
* property list. Returns negative on error. \since 0.9.11 */
-int pa_proplist_contains(pa_proplist *p, const char *key);
+int pa_proplist_contains(const pa_proplist *p, const char *key);
/** Remove all entries from the property list object. \since 0.9.11 */
void pa_proplist_clear(pa_proplist *p);
From bfe0b7dddbb4240a433fce520ac14b2573d45302 Mon Sep 17 00:00:00 2001
From: Lyndon Brown <[email protected]>
Date: Sun, 27 May 2018 04:40:07 +0100
Subject: proplist: pa_proplist_[size|isempty]: constify proplist pointer
diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index 4ad092d6..a0913b10 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -662,13 +662,13 @@ pa_proplist* pa_proplist_copy(const pa_proplist *p) {
return copy;
}
-unsigned pa_proplist_size(pa_proplist *p) {
+unsigned pa_proplist_size(const pa_proplist *p) {
pa_assert(p);
return pa_hashmap_size(MAKE_HASHMAP_CONST(p));
}
-int pa_proplist_isempty(pa_proplist *p) {
+int pa_proplist_isempty(const pa_proplist *p) {
pa_assert(p);
return pa_hashmap_isempty(MAKE_HASHMAP_CONST(p));
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index c148c793..2c99976f 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -397,10 +397,10 @@ void pa_proplist_clear(pa_proplist *p);
pa_proplist* pa_proplist_copy(const pa_proplist *p);
/** Return the number of entries in the property list. \since 0.9.15 */
-unsigned pa_proplist_size(pa_proplist *p);
+unsigned pa_proplist_size(const pa_proplist *p);
/** Returns 0 when the proplist is empty, positive otherwise \since 0.9.15 */
-int pa_proplist_isempty(pa_proplist *p);
+int pa_proplist_isempty(const pa_proplist *p);
/** Return non-zero when a and b have the same keys and values.
* \since 0.9.16 */
From a7691b4d5bc00e2c36529e2cee1db2dfbe645172 Mon Sep 17 00:00:00 2001
From: Lyndon Brown <[email protected]>
Date: Sun, 27 May 2018 04:42:36 +0100
Subject: proplist: pa_proplist_equal: constify proplist pointers
diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index a0913b10..91351159 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -674,7 +674,7 @@ int pa_proplist_isempty(const pa_proplist *p) {
return pa_hashmap_isempty(MAKE_HASHMAP_CONST(p));
}
-int pa_proplist_equal(pa_proplist *a, pa_proplist *b) {
+int pa_proplist_equal(const pa_proplist *a, const pa_proplist *b) {
const void *key = NULL;
struct property *a_prop = NULL;
struct property *b_prop = NULL;
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index 2c99976f..e50518b3 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -404,7 +404,7 @@ int pa_proplist_isempty(const pa_proplist *p);
/** Return non-zero when a and b have the same keys and values.
* \since 0.9.16 */
-int pa_proplist_equal(pa_proplist *a, pa_proplist *b);
+int pa_proplist_equal(const pa_proplist *a, const pa_proplist *b);
PA_C_DECL_END
From ccf32e018137472c2442bc3c00560926d3eb110c Mon Sep 17 00:00:00 2001
From: Lyndon Brown <[email protected]>
Date: Sun, 27 May 2018 05:14:04 +0100
Subject: scache: pa_context_play_sample_with_proplist: clarify proplist param
Existing documentation was unclear about which property list would be the
one changed (merged into), making it seem (along with the non-const
proplist pointer param, which needs changing seperately), that the proplist
object for which a pointer is given will be the one merged into, instead of
the internal cached entry's proplist.
diff --git a/src/pulse/scache.h b/src/pulse/scache.h
index 2b85854e..e4b82bc7 100644
--- a/src/pulse/scache.h
+++ b/src/pulse/scache.h
@@ -116,7 +116,7 @@ pa_operation* pa_context_play_sample_with_proplist(
const char *name /**< Name of the sample to play */,
const char *dev /**< Sink to play this sample on */,
pa_volume_t volume /**< Volume to play this sample with. Starting with 0.9.15 you may pass here PA_VOLUME_INVALID which will leave the decision about the volume to the server side, which is a good idea. */ ,
- pa_proplist *proplist /**< Property list for this sound. The property list of the cached entry will be merged into this property list */,
+ pa_proplist *proplist /**< Property list for this sound. The property list of the cached entry will have this merged into it. */,
pa_context_play_sample_cb_t cb /**< Call this function after successfully starting playback, or NULL */,
void *userdata /**< Userdata to pass to the callback */);
From 28f8c074a9bd9a1480121a09db12ed863280ad05 Mon Sep 17 00:00:00 2001
From: Lyndon Brown <[email protected]>
Date: Sun, 27 May 2018 05:15:14 +0100
Subject: scache: pa_context_play_sample_with_proplist: constify proplist param
diff --git a/src/pulse/scache.c b/src/pulse/scache.c
index de7b4112..f9da4631 100644
--- a/src/pulse/scache.c
+++ b/src/pulse/scache.c
@@ -205,7 +205,7 @@ pa_operation *pa_context_play_sample(pa_context *c, const char *name, const char
return o;
}
-pa_operation *pa_context_play_sample_with_proplist(pa_context *c, const char *name, const char *dev, pa_volume_t volume, pa_proplist *p, pa_context_play_sample_cb_t cb, void *userdata) {
+pa_operation *pa_context_play_sample_with_proplist(pa_context *c, const char *name, const char *dev, pa_volume_t volume, const pa_proplist *p, pa_context_play_sample_cb_t cb, void *userdata) {
pa_operation *o;
pa_tagstruct *t;
uint32_t tag;
diff --git a/src/pulse/scache.h b/src/pulse/scache.h
index e4b82bc7..1be71983 100644
--- a/src/pulse/scache.h
+++ b/src/pulse/scache.h
@@ -116,7 +116,7 @@ pa_operation* pa_context_play_sample_with_proplist(
const char *name /**< Name of the sample to play */,
const char *dev /**< Sink to play this sample on */,
pa_volume_t volume /**< Volume to play this sample with. Starting with 0.9.15 you may pass here PA_VOLUME_INVALID which will leave the decision about the volume to the server side, which is a good idea. */ ,
- pa_proplist *proplist /**< Property list for this sound. The property list of the cached entry will have this merged into it. */,
+ const pa_proplist *proplist /**< Property list for this sound. The property list of the cached entry will have this merged into it. */,
pa_context_play_sample_cb_t cb /**< Call this function after successfully starting playback, or NULL */,
void *userdata /**< Userdata to pass to the callback */);
_______________________________________________
pulseaudio-discuss mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss