context: hide error attr behind pointer

Paves the way towards more of the API using const pointers.

Some pa_context_* functions return their errors by setting the context
error, even when there's no other change in the context state. This
prevented constifying the pa_context arguments of such functions. This
patch puts the error in its own struct behind a pointer, so that setting
the error doesn't any more count as modifying the pa_context object.
This commit is contained in:
Lyndon Brown 2018-06-07 02:43:56 +01:00 committed by Arun Raghavan
parent 9472bebcb0
commit f727cd9ac0
2 changed files with 11 additions and 4 deletions

View file

@ -55,6 +55,10 @@
#define PA_PROTOCOL_FLAG_SHM 0x80000000U
#define PA_PROTOCOL_FLAG_MEMFD 0x40000000U
typedef struct pa_context_error {
int error;
} pa_context_error;
struct pa_context {
PA_REFCNT_DECLARE;
@ -80,7 +84,7 @@ struct pa_context {
uint32_t version;
uint32_t ctag;
uint32_t csyncid;
int error;
pa_context_error *error;
pa_context_state_t state;
pa_context_notify_cb_t state_callback;