mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-10-01 13:44:40 +00:00
fix detection of reallocarray
Fix detection of reallocarray (e.g. on glibc) raised since commit
0708a39b43
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
This commit is contained in:
parent
63d2102594
commit
85ca67b927
|
@ -375,6 +375,7 @@ check_functions = [
|
|||
['gettid', '#include <unistd.h>', ['-D_GNU_SOURCE'], []],
|
||||
['memfd_create', '#include <sys/mman.h>', ['-D_GNU_SOURCE'], []],
|
||||
['getrandom', '#include <stddef.h>\n#include <sys/random.h>', ['-D_GNU_SOURCE'], []],
|
||||
['reallocarray', '#include <stdlib.h>', ['-D_GNU_SOURCE'], []],
|
||||
['sigabbrev_np', '#include <string.h>', ['-D_GNU_SOURCE'], []],
|
||||
['XSetIOErrorExitHandler', '#include <X11/Xlib.h>', [], [x11_dep]],
|
||||
]
|
||||
|
|
|
@ -120,7 +120,7 @@ static jack_property_t *add_property(jack_description_t *desc, const char *key,
|
|||
|
||||
if (desc->property_cnt == desc->property_size) {
|
||||
ns = desc->property_size > 0 ? desc->property_size * 2 : 8;
|
||||
np = reallocarray(desc->properties, ns, sizeof(*prop));
|
||||
np = pw_reallocarray(desc->properties, ns, sizeof(*prop));
|
||||
if (np == NULL)
|
||||
return NULL;
|
||||
desc->property_size = ns;
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include <spa/utils/string.h>
|
||||
#include <spa/utils/json.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "codec-loader.h"
|
||||
#include "player.h"
|
||||
#include "defs.h"
|
||||
|
@ -1579,7 +1580,11 @@ const struct a2dp_codec **spa_bt_device_get_supported_a2dp_codecs(struct spa_bt_
|
|||
if (j >= size) {
|
||||
const struct a2dp_codec **p;
|
||||
size = size * 2;
|
||||
#ifdef HAVE_REALLOCARRRAY
|
||||
p = reallocarray(supported_codecs, size, sizeof(const struct a2dp_codec *));
|
||||
#else
|
||||
p = realloc(supported_codecs, size * sizeof(const struct a2dp_codec *));
|
||||
#endif
|
||||
if (p == NULL) {
|
||||
free(supported_codecs);
|
||||
return NULL;
|
||||
|
|
|
@ -191,7 +191,7 @@ static int update_params(struct params *p, uint32_t n_params, const struct spa_p
|
|||
p->params = NULL;
|
||||
} else {
|
||||
struct spa_pod **np;
|
||||
np = reallocarray(p->params, p->n_params, sizeof(struct spa_pod *));
|
||||
np = pw_reallocarray(p->params, p->n_params, sizeof(struct spa_pod *));
|
||||
if (np == NULL) {
|
||||
pw_log_error("%p: can't realloc: %m", p);
|
||||
free(p->params);
|
||||
|
|
|
@ -318,7 +318,7 @@ static int add_node_update(struct node_data *data, uint32_t change_mask, uint32_
|
|||
id, &idx, NULL, ¶m, &b.b);
|
||||
if (res == 1) {
|
||||
void *p;
|
||||
p = reallocarray(params, n_params + 1, sizeof(struct spa_pod *));
|
||||
p = pw_reallocarray(params, n_params + 1, sizeof(struct spa_pod *));
|
||||
if (p == NULL) {
|
||||
res = -errno;
|
||||
pw_log_error("realloc failed: %m");
|
||||
|
@ -384,7 +384,7 @@ static int add_port_update(struct node_data *data, struct pw_impl_port *port, ui
|
|||
id, &idx, NULL, ¶m, &b.b);
|
||||
if (res == 1) {
|
||||
void *p;
|
||||
p = reallocarray(params, n_params + 1, sizeof(struct spa_pod*));
|
||||
p = pw_reallocarray(params, n_params + 1, sizeof(struct spa_pod*));
|
||||
if (p == NULL) {
|
||||
res = -errno;
|
||||
pw_log_error("realloc failed: %m");
|
||||
|
|
|
@ -476,7 +476,7 @@ do_update_port(struct node *this,
|
|||
port->params = NULL;
|
||||
} else {
|
||||
void *p;
|
||||
p = reallocarray(port->params, port->n_params, sizeof(struct spa_pod *));
|
||||
p = pw_reallocarray(port->params, port->n_params, sizeof(struct spa_pod *));
|
||||
if (p == NULL) {
|
||||
pw_log_error("%p: port %u can't realloc: %m", this, port_id);
|
||||
free(port->params);
|
||||
|
@ -1049,7 +1049,7 @@ client_node0_update(void *data,
|
|||
this->params = NULL;
|
||||
} else {
|
||||
void *p;
|
||||
p = reallocarray(this->params, this->n_params, sizeof(struct spa_pod *));
|
||||
p = pw_reallocarray(this->params, this->n_params, sizeof(struct spa_pod *));
|
||||
if (p == NULL) {
|
||||
pw_log_error("%p: can't realloc: %m", this);
|
||||
free(this->params);
|
||||
|
|
|
@ -196,7 +196,7 @@ int endpoint_stream_update(struct endpoint_stream *this,
|
|||
this->params = NULL;
|
||||
} else {
|
||||
void *p;
|
||||
p = reallocarray(this->params, n_params, sizeof(struct spa_pod*));
|
||||
p = pw_reallocarray(this->params, n_params, sizeof(struct spa_pod*));
|
||||
if (p == NULL) {
|
||||
free(this->params);
|
||||
this->params = NULL;
|
||||
|
@ -227,7 +227,7 @@ int endpoint_stream_update(struct endpoint_stream *this,
|
|||
this->info.params = NULL;
|
||||
} else {
|
||||
void *p;
|
||||
p = reallocarray(this->info.params, info->n_params, sizeof(struct spa_param_info));
|
||||
p = pw_reallocarray(this->info.params, info->n_params, sizeof(struct spa_param_info));
|
||||
if (p == NULL) {
|
||||
free(this->info.params);
|
||||
this->info.params = NULL;
|
||||
|
|
|
@ -213,7 +213,7 @@ int endpoint_update(struct endpoint *this,
|
|||
this->params = NULL;
|
||||
} else {
|
||||
void *p;
|
||||
p = reallocarray(this->params, n_params, sizeof(struct spa_pod*));
|
||||
p = pw_reallocarray(this->params, n_params, sizeof(struct spa_pod*));
|
||||
if (p == NULL) {
|
||||
free(this->params);
|
||||
this->params = NULL;
|
||||
|
@ -245,7 +245,7 @@ int endpoint_update(struct endpoint *this,
|
|||
this->info.params = NULL;
|
||||
} else {
|
||||
void *p;
|
||||
p = reallocarray(this->info.params, info->n_params, sizeof(struct spa_param_info));
|
||||
p = pw_reallocarray(this->info.params, info->n_params, sizeof(struct spa_param_info));
|
||||
if (p == NULL) {
|
||||
free(this->info.params);
|
||||
this->info.params = NULL;
|
||||
|
|
|
@ -209,7 +209,7 @@ int endpoint_link_update(struct endpoint_link *this,
|
|||
this->params = NULL;
|
||||
} else {
|
||||
void *p;
|
||||
p = reallocarray(this->params, n_params, sizeof(struct spa_pod*));
|
||||
p = pw_reallocarray(this->params, n_params, sizeof(struct spa_pod*));
|
||||
if (p == NULL) {
|
||||
free(this->params);
|
||||
this->params = NULL;
|
||||
|
@ -241,7 +241,7 @@ int endpoint_link_update(struct endpoint_link *this,
|
|||
this->info.params = NULL;
|
||||
} else {
|
||||
void *p;
|
||||
p = reallocarray(this->info.params, info->n_params, sizeof(struct spa_param_info));
|
||||
p = pw_reallocarray(this->info.params, info->n_params, sizeof(struct spa_param_info));
|
||||
if (p == NULL) {
|
||||
free(this->info.params);
|
||||
this->info.params = NULL;
|
||||
|
|
|
@ -196,7 +196,7 @@ int session_update(struct session *this,
|
|||
this->params = NULL;
|
||||
} else {
|
||||
void *p;
|
||||
p = reallocarray(this->params, n_params, sizeof(struct spa_pod*));
|
||||
p = pw_reallocarray(this->params, n_params, sizeof(struct spa_pod*));
|
||||
if (p == NULL) {
|
||||
free(this->params);
|
||||
this->params = NULL;
|
||||
|
@ -222,7 +222,7 @@ int session_update(struct session *this,
|
|||
this->info.params = NULL;
|
||||
} else {
|
||||
void *p;
|
||||
p = reallocarray(this->info.params, info->n_params, sizeof(struct spa_param_info));
|
||||
p = pw_reallocarray(this->info.params, info->n_params, sizeof(struct spa_param_info));
|
||||
if (p == NULL) {
|
||||
free(this->info.params);
|
||||
this->info.params = NULL;
|
||||
|
|
|
@ -213,7 +213,7 @@ struct pw_node_info *pw_node_info_merge(struct pw_node_info *info,
|
|||
uint32_t i, user, n_params = update->n_params;
|
||||
void *np;
|
||||
|
||||
np = reallocarray(info->params, n_params, sizeof(struct spa_param_info));
|
||||
np = pw_reallocarray(info->params, n_params, sizeof(struct spa_param_info));
|
||||
if (np == NULL) {
|
||||
free(info->params);
|
||||
info->params = NULL;
|
||||
|
@ -283,7 +283,7 @@ struct pw_port_info *pw_port_info_merge(struct pw_port_info *info,
|
|||
uint32_t i, user, n_params = update->n_params;
|
||||
void *np;
|
||||
|
||||
np = reallocarray(info->params, n_params, sizeof(struct spa_param_info));
|
||||
np = pw_reallocarray(info->params, n_params, sizeof(struct spa_param_info));
|
||||
if (np == NULL) {
|
||||
free(info->params);
|
||||
info->params = NULL;
|
||||
|
@ -443,7 +443,7 @@ struct pw_device_info *pw_device_info_merge(struct pw_device_info *info,
|
|||
uint32_t i, user, n_params = update->n_params;
|
||||
void *np;
|
||||
|
||||
np = reallocarray(info->params, n_params, sizeof(struct spa_param_info));
|
||||
np = pw_reallocarray(info->params, n_params, sizeof(struct spa_param_info));
|
||||
if (np == NULL) {
|
||||
free(info->params);
|
||||
info->params = NULL;
|
||||
|
|
|
@ -168,3 +168,13 @@ ssize_t pw_getrandom(void *buf, size_t buflen, unsigned int flags)
|
|||
close(fd);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
void* pw_reallocarray(void *ptr, size_t nmemb, size_t size)
|
||||
{
|
||||
#ifdef HAVE_REALLOCARRAY
|
||||
return reallocarray(ptr, nmemb, size);
|
||||
#else
|
||||
return realloc(ptr, nmemb * size);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -88,9 +88,8 @@ pw_strip(char *str, const char *whitespace);
|
|||
|
||||
ssize_t pw_getrandom(void *buf, size_t buflen, unsigned int flags);
|
||||
|
||||
#if !defined(reallocarray)
|
||||
# define reallocarray(ptr,nmemb,size) realloc((ptr), (nmemb) * (size))
|
||||
#endif
|
||||
void* pw_reallocarray(void *ptr, size_t nmemb, size_t size);
|
||||
|
||||
/**
|
||||
* \}
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue