spa/buffer: rename SPA_MEMBER to SPA_PTROFF

SPA_MEMBER is misleading, all we're doing here is pointer+offset and a
type-casting the result. Rename to SPA_PTROFF which is more expressive (and
has the same number of characters so we don't need to re-indent).
This commit is contained in:
Peter Hutterer 2021-05-06 13:41:44 +10:00 committed by Wim Taymans
parent e598d0a422
commit 2405f0942b
92 changed files with 248 additions and 227 deletions

View file

@ -134,7 +134,7 @@ static struct pw_manager_param *add_param(struct spa_list *params,
p->id = id;
if (param != NULL) {
p->param = SPA_MEMBER(p, sizeof(*p), struct spa_pod);
p->param = SPA_PTROFF(p, sizeof(*p), struct spa_pod);
memcpy(p->param, param, SPA_POD_SIZE(param));
} else {
clear_params(params, id);
@ -836,7 +836,7 @@ void *pw_manager_object_add_data(struct pw_manager_object *obj, const char *id,
spa_list_append(&o->data_list, &d->link);
done:
return SPA_MEMBER(d, sizeof(struct object_data), void);
return SPA_PTROFF(d, sizeof(struct object_data), void);
}
int pw_manager_sync(struct pw_manager *manager)

View file

@ -226,10 +226,10 @@ static int read_arbitrary(struct message *m, const void **val, size_t *length)
static int read_string(struct message *m, char **str)
{
uint32_t n, maxlen = m->length - m->offset;
n = strnlen(SPA_MEMBER(m->data, m->offset, char), maxlen);
n = strnlen(SPA_PTROFF(m->data, m->offset, char), maxlen);
if (n == maxlen)
return -EINVAL;
*str = SPA_MEMBER(m->data, m->offset, char);
*str = SPA_PTROFF(m->data, m->offset, char);
m->offset += n + 1;
return 0;
}
@ -481,7 +481,7 @@ static void write_string(struct message *m, const char *s)
if (s != NULL) {
int len = strlen(s) + 1;
if (ensure_size(m, len) > 0)
strcpy(SPA_MEMBER(m->data, m->length, char), s);
strcpy(SPA_PTROFF(m->data, m->length, char), s);
m->length += len;
}
}

View file

@ -50,7 +50,7 @@ struct module *module_new(struct impl *impl, const struct module_methods *method
module->impl = impl;
module->methods = methods;
spa_hook_list_init(&module->hooks);
module->user_data = SPA_MEMBER(module, sizeof(struct module), void);
module->user_data = SPA_PTROFF(module, sizeof(struct module), void);
return module;
}

View file

@ -226,7 +226,7 @@ static int flush_messages(struct client *client)
desc.offset_lo = 0;
desc.flags = 0;
data = SPA_MEMBER(&desc, client->out_index, void);
data = SPA_PTROFF(&desc, client->out_index, void);
size = sizeof(desc) - client->out_index;
} else if (client->out_index < m->length + sizeof(desc)) {
uint32_t idx = client->out_index - sizeof(desc);
@ -1705,7 +1705,7 @@ static void stream_process(void *data)
spa_ringbuffer_write_data(&stream->ring,
stream->buffer, stream->attr.maxlength,
pd.write_index % stream->attr.maxlength,
SPA_MEMBER(p, buf->datas[0].chunk->offset, void),
SPA_PTROFF(p, buf->datas[0].chunk->offset, void),
SPA_MIN(size, stream->attr.maxlength));
pd.write_index += size;
@ -5532,7 +5532,7 @@ static int do_read(struct client *client)
int res = 0;
if (client->in_index < sizeof(client->desc)) {
data = SPA_MEMBER(&client->desc, client->in_index, void);
data = SPA_PTROFF(&client->desc, client->in_index, void);
size = sizeof(client->desc) - client->in_index;
} else {
uint32_t idx = client->in_index - sizeof(client->desc);
@ -5541,7 +5541,7 @@ static int do_read(struct client *client)
res = -EIO;
goto exit;
}
data = SPA_MEMBER(client->message->data, idx, void);
data = SPA_PTROFF(client->message->data, idx, void);
size = client->message->length - idx;
}
while (true) {
@ -6325,7 +6325,7 @@ error_exit:
void *pw_protocol_pulse_get_user_data(struct pw_protocol_pulse *pulse)
{
return SPA_MEMBER(pulse, sizeof(struct impl), void);
return SPA_PTROFF(pulse, sizeof(struct impl), void);
}
void pw_protocol_pulse_destroy(struct pw_protocol_pulse *pulse)

View file

@ -178,7 +178,7 @@ static struct sample_play *sample_play_new(struct pw_core *core,
p->context = pw_core_get_context(core);
p->main_loop = pw_context_get_main_loop(p->context);
spa_hook_list_init(&p->hooks);
p->user_data = SPA_MEMBER(p, sizeof(struct sample_play), void);
p->user_data = SPA_PTROFF(p, sizeof(struct sample_play), void);
pw_properties_update(props, &sample->props->dict);