[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] message-params: Fix array reading functions
PulseAudio Marge Bot
gitlab at gitlab.freedesktop.org
Sat Jan 2 17:32:35 UTC 2021
PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio
Commits:
81ebd8ba by Georg Chini at 2021-01-01T20:43:07+00:00
message-params: Fix array reading functions
The array read functions need the state pointer as an additional argument because the
array may be in the middle of a parameter list and the state pointer must be advanced
to the element after the array.
Additionally fixes some compiler warnings.
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/450>
- - - - -
2 changed files:
- src/pulse/message-params.c
- src/pulse/message-params.h
Changes:
=====================================
src/pulse/message-params.c
=====================================
@@ -345,9 +345,9 @@ int pa_message_params_read_bool(char *c, bool *result, void **state) {
}
/* Converts a parameter list to a string array. */
-int pa_message_params_read_string_array(char *c, const char ***results, int *length) {
- void *state = NULL;
- uint32_t element_count, i;
+int pa_message_params_read_string_array(char *c, const char ***results, int *length, void **state) {
+ void *state1 = NULL;
+ int element_count, i;
int err;
const char **values;
char *start_pos;
@@ -370,8 +370,7 @@ int pa_message_params_read_string_array(char *c, const char ***results, int *len
/* Allocate array */
values = pa_xmalloc0(element_count * sizeof(char *));
- state = NULL;
- for (i = 0; (err = pa_message_params_read_string(start_pos, &(values[i]), &state)) > 0; i++)
+ for (i = 0; (err = pa_message_params_read_string(start_pos, &(values[i]), &state1)) > 0; i++)
;
if (err < 0) {
@@ -386,10 +385,10 @@ int pa_message_params_read_string_array(char *c, const char ***results, int *len
}
/* Converts a parameter list to a double array. */
-int pa_message_params_read_double_array(char *c, double **results, int *length) {
+int pa_message_params_read_double_array(char *c, double **results, int *length, void **state) {
double *values;
- void *state = NULL;
- uint32_t element_count, i;
+ void *state1 = NULL;
+ int element_count, i;
int err;
char *start_pos;
@@ -411,8 +410,7 @@ int pa_message_params_read_double_array(char *c, double **results, int *length)
/* Allocate array */
values = pa_xmalloc0(element_count * sizeof(double));
- state = NULL;
- for (i = 0; (err = pa_message_params_read_double(start_pos, &(values[i]), &state)) > 0; i++)
+ for (i = 0; (err = pa_message_params_read_double(start_pos, &(values[i]), &state1)) > 0; i++)
;
if (err < 0) {
@@ -427,10 +425,10 @@ int pa_message_params_read_double_array(char *c, double **results, int *length)
}
/* Converts a parameter list to an int64 array. */
-int pa_message_params_read_int64_array(char *c, int64_t **results, int *length) {
+int pa_message_params_read_int64_array(char *c, int64_t **results, int *length, void **state) {
int64_t *values;
- void *state = NULL;
- uint32_t element_count, i;
+ void *state1 = NULL;
+ int element_count, i;
int err;
char *start_pos;
@@ -452,8 +450,7 @@ int pa_message_params_read_int64_array(char *c, int64_t **results, int *length)
/* Allocate array */
values = pa_xmalloc0(element_count * sizeof(int64_t));
- state = NULL;
- for (i = 0; (err = pa_message_params_read_int64(start_pos, &(values[i]), &state)) > 0; i++)
+ for (i = 0; (err = pa_message_params_read_int64(start_pos, &(values[i]), &state1)) > 0; i++)
;
if (err < 0) {
@@ -468,10 +465,10 @@ int pa_message_params_read_int64_array(char *c, int64_t **results, int *length)
}
/* Converts a parameter list to an uint64 array. */
-int pa_message_params_read_uint64_array(char *c, uint64_t **results, int *length) {
+int pa_message_params_read_uint64_array(char *c, uint64_t **results, int *length, void **state) {
uint64_t *values;
- void *state = NULL;
- uint32_t element_count, i;
+ void *state1 = NULL;
+ int element_count, i;
int err;
char *start_pos;
@@ -493,8 +490,7 @@ int pa_message_params_read_uint64_array(char *c, uint64_t **results, int *length
/* Allocate array */
values = pa_xmalloc0(element_count * sizeof(uint64_t));
- state = NULL;
- for (i = 0; (err = pa_message_params_read_uint64(start_pos, &(values[i]), &state)) > 0; i++)
+ for (i = 0; (err = pa_message_params_read_uint64(start_pos, &(values[i]), &state1)) > 0; i++)
;
if (err < 0) {
=====================================
src/pulse/message-params.h
=====================================
@@ -77,7 +77,7 @@ int pa_message_params_read_double(char *c, double *result, void **state);
/** Converts a parameter list to a double array. Empty elements in the parameter
* list are treated as error. Returns allocated array in *results and array size in *length.
* The returned array must be freed with pa_xfree(). \since 15.0 */
-int pa_message_params_read_double_array(char *c, double **results, int *length);
+int pa_message_params_read_double_array(char *c, double **results, int *length, void **state);
/** Read an integer from parameter list in c. \since 15.0 */
int pa_message_params_read_int64(char *c, int64_t *result, void **state);
@@ -85,7 +85,7 @@ int pa_message_params_read_int64(char *c, int64_t *result, void **state);
/** Converts a parameter list to an int64 array. Empty elements in the parameter
* list are treated as error. Returns allocated array in *results and array size in *length.
* The returned array must be freed with pa_xfree(). \since 15.0 */
-int pa_message_params_read_int64_array(char *c, int64_t **results, int *length);
+int pa_message_params_read_int64_array(char *c, int64_t **results, int *length, void **state);
/** Read raw data from parameter list in c. Used to split a message parameter
* string into list elements. The string returned in *result must not be freed. \since 15.0 */
@@ -99,7 +99,7 @@ int pa_message_params_read_string(char *c, const char **result, void **state);
* the strings. Returns allocated array of pointers to sub-strings within c in
* *results and stores array size in *length. The returned array must be
* freed with pa_xfree(), but not the strings within the array. \since 15.0 */
-int pa_message_params_read_string_array(char *c, const char ***results, int *length);
+int pa_message_params_read_string_array(char *c, const char ***results, int *length, void **state);
/** Read an unsigned integer from parameter list in c. \since 15.0 */
int pa_message_params_read_uint64(char *c, uint64_t *result, void **state);
@@ -107,7 +107,7 @@ int pa_message_params_read_uint64(char *c, uint64_t *result, void **state);
/** Converts a parameter list to an uint64 array. Empty elements in the parameter
* list are treated as error. Returns allocated array in *results and array size in *length.
* The returned array must be freed with pa_xfree(). \since 15.0 */
-int pa_message_params_read_uint64_array(char *c, uint64_t **results, int *length);
+int pa_message_params_read_uint64_array(char *c, uint64_t **results, int *length, void **state);
/** @} */
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/81ebd8ba3f644e95a7f858ede9fc65d340ab06e2
--
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/81ebd8ba3f644e95a7f858ede9fc65d340ab06e2
You're receiving this email because of your account on gitlab.freedesktop.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20210102/fb3e8611/attachment-0001.htm>
More information about the pulseaudio-commits
mailing list