From 13e8caac56358fb1213cff96e18d90eb72fec908 Mon Sep 17 00:00:00 2001 From: cosinus Date: Sun, 12 Jan 2025 14:09:44 +0100 Subject: [PATCH] Fix formating --- src/util/pointer.h | 49 +++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/src/util/pointer.h b/src/util/pointer.h index 5943c9bb2b869..0ec613e1559e4 100644 --- a/src/util/pointer.h +++ b/src/util/pointer.h @@ -36,10 +36,9 @@ class Buffer Buffer(unsigned int size) { m_size = size; - if(size != 0) { + if (size != 0) { data = new T[size]; - } - else { + } else { data = nullptr; } } @@ -51,25 +50,24 @@ class Buffer Buffer(Buffer &&buffer) { m_size = buffer.m_size; - if(m_size != 0) - { + if (m_size != 0) { data = buffer.data; buffer.data = nullptr; buffer.m_size = 0; - } - else + } else { data = nullptr; + } } // Copies whole buffer Buffer(const T *t, unsigned int size) { m_size = size; - if(size != 0) { + if (size != 0) { data = new T[size]; memcpy(data, t, sizeof(T) * size); - } - else + } else { data = nullptr; + } } ~Buffer() @@ -79,16 +77,16 @@ class Buffer Buffer& operator=(Buffer &&buffer) { - if(this == &buffer) + if (this == &buffer) { return *this; + } drop(); m_size = buffer.m_size; - if(m_size != 0) { + if (m_size != 0) { data = buffer.data; buffer.data = nullptr; buffer.m_size = 0; - } - else { + } else { data = nullptr; } return *this; @@ -122,8 +120,9 @@ class Buffer operator std::string_view() const { - if (!data) + if (!data) { return std::string_view(); + } return std::string_view(reinterpret_cast(data), m_size); } @@ -157,10 +156,9 @@ class SharedBuffer SharedBuffer(unsigned int size) { m_size = size; - if(m_size != 0) { + if (m_size != 0) { data = new T[m_size]; - } - else { + } else { data = nullptr; } @@ -177,7 +175,7 @@ class SharedBuffer } SharedBuffer & operator=(const SharedBuffer & buffer) { - if(this == &buffer) { + if (this == &buffer) { return *this; } @@ -194,11 +192,10 @@ class SharedBuffer SharedBuffer(const T *t, unsigned int size) { m_size = size; - if(m_size != 0) { + if (m_size != 0) { data = new T[m_size]; memcpy(data, t, sizeof(T) * m_size); - } - else { + } else { data = nullptr; } refcount = new unsigned int; @@ -207,14 +204,13 @@ class SharedBuffer /* Copies whole buffer */ - SharedBuffer(const Buffer &buffer) + SharedBuffer(const Buffer &buffer) : SharedBuffer(*buffer, buffer.getSize()) { m_size = buffer.getSize(); if (m_size != 0) { data = new T[m_size]; memcpy(data, *buffer, sizeof(T) * m_size); - } - else { + } else { data = nullptr; } @@ -247,8 +243,7 @@ class SharedBuffer { assert((*refcount) > 0); (*refcount)--; - if(*refcount == 0) - { + if (*refcount == 0) { delete[] data; delete refcount; }