summaryrefslogtreecommitdiff
path: root/source/libs/asura-lib-utils/io/data_buffer.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-06-06 00:12:17 +0800
committerchai <chaifix@163.com>2019-06-06 00:12:17 +0800
commit8bfe54676f728076a92d802bb5d064e58265c8f2 (patch)
tree5d8ea1bd063f2d01dc979915db546449d68277bf /source/libs/asura-lib-utils/io/data_buffer.cpp
parent88b882ed0b432c6aff2063213e2f793a36dd25f7 (diff)
-文件夹名
Diffstat (limited to 'source/libs/asura-lib-utils/io/data_buffer.cpp')
-rw-r--r--source/libs/asura-lib-utils/io/data_buffer.cpp102
1 files changed, 0 insertions, 102 deletions
diff --git a/source/libs/asura-lib-utils/io/data_buffer.cpp b/source/libs/asura-lib-utils/io/data_buffer.cpp
deleted file mode 100644
index 5049b38..0000000
--- a/source/libs/asura-lib-utils/io/data_buffer.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-#include <cstdlib>
-#include <cstring>
-#include "data_buffer.h"
-
-using namespace AEThreading;
-
-namespace AsuraEngine
-{
- namespace IO
- {
-
- DataBuffer::DataBuffer(DataBuffer& src)
- {
- Load(src);
- }
-
- DataBuffer::DataBuffer(std::size_t size)
- : mSize(size)
- , mBytes(nullptr)
- {
- lock(mMutex);
- mBytes = new byte[size];
- memset(mBytes, 0, size);
- }
-
- DataBuffer::DataBuffer(const void* data, std::size_t size)
- : mSize(size)
- , mBytes(nullptr)
- {
- Load(data, size);
- }
-
- DataBuffer::~DataBuffer()
- {
- delete[] mBytes;
- }
-
- void DataBuffer::Refactor(size_t size)
- {
- lock(mMutex);
- if (!mBytes || mSize != size)
- {
- delete[] mBytes;
- mBytes = new byte[size];
- mSize = size;
- }
- memset(mBytes, 0, size * sizeof(byte));
- }
-
- size_t DataBuffer::Load(DataBuffer& db)
- {
- return Load(db.GetData(), db.GetSize());
- }
-
- size_t DataBuffer::Load(const void* data, std::size_t size)
- {
- lock(mMutex);
- size_t len = mSize > size ? size : mSize;
- memcpy(mBytes, data, len);
- return len;
- }
-
- void DataBuffer::Move(void* bytes, std::size_t size)
- {
- lock(mMutex);
- if (!mBytes)
- {
- delete[] mBytes;
- }
- mBytes = (byte*)bytes;
- mSize = size;
- }
-
- byte* DataBuffer::GetData()
- {
- return mBytes;
- }
-
- void DataBuffer::Clear()
- {
- lock(mMutex);
- if (mBytes)
- memset(mBytes, 0, mSize);
- }
-
- std::size_t DataBuffer::GetSize()
- {
- return mSize;
- }
-
- void DataBuffer::Lock()
- {
- mMutex.Lock();
- }
-
- void DataBuffer::Unlock()
- {
- mMutex.Unlock();
- }
-
- }
-} \ No newline at end of file