mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-07 13:30:09 -05:00
module-profiler: avoid large stack alloc
If the profiler manages to fill the complete buffer, we would have 8MB of data that we need to allocate on the stack. Don't do that and instead use a preallocated buffer large enough to copy things into.
This commit is contained in:
parent
830f52cbb1
commit
9ce87aacd2
1 changed files with 4 additions and 3 deletions
|
|
@ -80,6 +80,8 @@ struct impl {
|
||||||
|
|
||||||
struct spa_ringbuffer buffer;
|
struct spa_ringbuffer buffer;
|
||||||
uint8_t data[MAX_BUFFER];
|
uint8_t data[MAX_BUFFER];
|
||||||
|
|
||||||
|
uint8_t flush[MAX_BUFFER + sizeof(struct spa_pod_struct)];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct resource_data {
|
struct resource_data {
|
||||||
|
|
@ -121,7 +123,7 @@ static void stop_flush(struct impl *impl)
|
||||||
static void flush_timeout(void *data, uint64_t expirations)
|
static void flush_timeout(void *data, uint64_t expirations)
|
||||||
{
|
{
|
||||||
struct impl *impl = data;
|
struct impl *impl = data;
|
||||||
int32_t avail, size;
|
int32_t avail;
|
||||||
uint32_t idx;
|
uint32_t idx;
|
||||||
struct spa_pod_struct *p;
|
struct spa_pod_struct *p;
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
|
|
@ -137,8 +139,7 @@ static void flush_timeout(void *data, uint64_t expirations)
|
||||||
}
|
}
|
||||||
impl->empty = 0;
|
impl->empty = 0;
|
||||||
|
|
||||||
size = avail + sizeof(struct spa_pod_struct);
|
p = (struct spa_pod_struct *)impl->flush;
|
||||||
p = alloca(size);
|
|
||||||
*p = SPA_POD_INIT_Struct(avail);
|
*p = SPA_POD_INIT_Struct(avail);
|
||||||
|
|
||||||
spa_ringbuffer_read_data(&impl->buffer, impl->data, MAX_BUFFER,
|
spa_ringbuffer_read_data(&impl->buffer, impl->data, MAX_BUFFER,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue