mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-10 13:29:58 -05:00
core: Replace PA_PAGE_SIZE with pa_page_size()
PA_PAGE_SIZE using sysconf() may return a negative number CID 1137925, CID 1137926, CID 1138485 instead of calling sysconf() directly, add function pa_page_size() which uses the guestimate 4096 in case sysconf(_SC_PAGE_SIZE) fails using PA_ONCE to only evaluate sysconf() once
This commit is contained in:
parent
c99efbffd6
commit
45d9030638
10 changed files with 55 additions and 38 deletions
|
|
@ -828,13 +828,14 @@ static void memblock_replace_import(pa_memblock *b) {
|
|||
pa_mempool *pa_mempool_new(pa_mem_type_t type, size_t size, bool per_client) {
|
||||
pa_mempool *p;
|
||||
char t1[PA_BYTES_SNPRINT_MAX], t2[PA_BYTES_SNPRINT_MAX];
|
||||
const size_t page_size = pa_page_size();
|
||||
|
||||
p = pa_xnew0(pa_mempool, 1);
|
||||
PA_REFCNT_INIT(p);
|
||||
|
||||
p->block_size = PA_PAGE_ALIGN(PA_MEMPOOL_SLOT_SIZE);
|
||||
if (p->block_size < PA_PAGE_SIZE)
|
||||
p->block_size = PA_PAGE_SIZE;
|
||||
if (p->block_size < page_size)
|
||||
p->block_size = page_size;
|
||||
|
||||
if (size <= 0)
|
||||
p->n_blocks = PA_MEMPOOL_SLOTS_MAX;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue