From eb046e2295ee30e88a2878a11e114425ce6f81b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 6 Mar 2018 20:13:59 +0100 Subject: [PATCH] Fix deprecation warnings on DMD 2.079.0. --- source/vibe/internal/array.d | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/source/vibe/internal/array.d b/source/vibe/internal/array.d index ed5e633..44fb128 100644 --- a/source/vibe/internal/array.d +++ b/source/vibe/internal/array.d @@ -304,7 +304,7 @@ struct FixedRingBuffer(T, size_t N = 0, bool INITIALIZE = true) { static if( N == 0 ){ bool m_freeOnDestruct; this(size_t capacity) { m_buffer = new T[capacity]; } - ~this() { if (m_freeOnDestruct && m_buffer.length > 0) delete m_buffer; } + ~this() { if (m_freeOnDestruct && m_buffer.length > 0) deleteCompat(m_buffer); } } @property bool empty() const { return m_fill == 0; } @@ -323,7 +323,7 @@ struct FixedRingBuffer(T, size_t N = 0, bool INITIALIZE = true) { /// Resets the capacity to zero and explicitly frees the memory for the buffer. void dispose() { - delete m_buffer; + deleteCompat(m_buffer); m_buffer = null; m_start = m_fill = 0; } @@ -336,14 +336,14 @@ struct FixedRingBuffer(T, size_t N = 0, bool INITIALIZE = true) { auto newfill = min(m_fill, new_size); read(dst[0 .. newfill]); if (m_freeOnDestruct && m_buffer.length > 0) () @trusted { - delete m_buffer; + deleteCompat(m_buffer); } (); m_buffer = newbuffer; m_start = 0; m_fill = newfill; } else { if (m_freeOnDestruct && m_buffer.length > 0) () @trusted { - delete m_buffer; + deleteCompat(m_buffer); } (); m_buffer = new T[new_size]; } @@ -649,3 +649,11 @@ struct ArraySet(Key) foreach (ref k; m_entries) if (k == key) { k = Key.init; return; } } } + +private void deleteCompat(T)(ref T v) +{ + static if (__VERSION__ >= 2079) { + import core.memory : __delete; + __delete(v); + } else mixin("delete v;"); +}