pulse: inline the message check

Inline the resize check and then call the resize function when
necessary.
This commit is contained in:
Wim Taymans 2026-05-26 14:48:47 +02:00
parent 7ce0b0f339
commit 753ed37ec5

View file

@ -377,18 +377,12 @@ done:
return res;
}
static int ensure_size(struct message *m, uint32_t size)
static int message_resize(struct message *m, uint32_t size)
{
uint64_t needed;
uint32_t alloc, diff;
void *data;
if (m->length > m->allocated)
return -ENOMEM;
if (size <= m->allocated - m->length)
return size;
needed = SPA_ROUND_UP_N(SPA_MAX((uint64_t)m->allocated + size, 4096u), 4096u);
if (needed > UINT32_MAX)
return -ENOMEM;
@ -408,6 +402,17 @@ static int ensure_size(struct message *m, uint32_t size)
return size;
}
static inline int ensure_size(struct message *m, uint32_t size)
{
if (m->length > m->allocated)
return -ENOMEM;
if (size <= m->allocated - m->length)
return size;
return message_resize(m, size);
}
static void write_8(struct message *m, uint8_t val)
{
if (ensure_size(m, 1) > 0)