diff options
author | Chris Robinson <chris.kcat@gmail.com> | 2018-12-27 12:55:43 -0800 |
---|---|---|
committer | Chris Robinson <chris.kcat@gmail.com> | 2018-12-27 12:55:43 -0800 |
commit | 1a4387d137acb57f69a2b5d073faf55d4a4c32ed (patch) | |
tree | 70b19a7ffa44c148c76996e3f715b0dff795dd4c /Alc/ringbuffer.cpp | |
parent | 323cf58f02bd2a8a92006a5ee20014d2eb8ff3a9 (diff) |
Return unique_ptrs instead of raw pointers
For the ring buffer, channel converter, and sample converter.
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; } |