diff options
Diffstat (limited to 'Alc/ringbuffer.cpp')
-rw-r--r-- | Alc/ringbuffer.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/Alc/ringbuffer.cpp b/Alc/ringbuffer.cpp index 9e531316..767db246 100644 --- a/Alc/ringbuffer.cpp +++ b/Alc/ringbuffer.cpp @@ -33,11 +33,9 @@ #include "compat.h" -RingBuffer *ll_ringbuffer_create(size_t sz, size_t elem_sz, int limit_writes) +RingBufferPtr CreateRingBuffer(size_t sz, size_t elem_sz, int limit_writes) { - RingBuffer *rb; - size_t power_of_two = 0; - + size_t power_of_two{0u}; if(sz > 0) { power_of_two = sz; @@ -50,14 +48,14 @@ RingBuffer *ll_ringbuffer_create(size_t sz, size_t elem_sz, int limit_writes) power_of_two |= power_of_two>>32; #endif } - power_of_two++; - if(power_of_two < sz) return NULL; - - rb = new (al_malloc(16, sizeof(*rb) + power_of_two*elem_sz)) RingBuffer{}; + ++power_of_two; + if(power_of_two < sz) return nullptr; + RingBufferPtr rb{new (al_malloc(16, sizeof(*rb) + power_of_two*elem_sz)) RingBuffer{}}; rb->mSize = limit_writes ? sz : power_of_two; rb->mSizeMask = power_of_two - 1; rb->mElemSize = elem_sz; + return rb; } |