-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbuffer.cpp
More file actions
70 lines (54 loc) · 1.1 KB
/
dbuffer.cpp
File metadata and controls
70 lines (54 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "dbuffer.hpp"
#include <string>
#include <iostream>
namespace Destruct
{
/*
* RealBuffer
*/
RealBuffer::RealBuffer() : data(NULL), size(0)
{
}
RealBuffer::RealBuffer(int32_t size_) : data(new uint8_t[size_]), size(size_)
{
}
RealBuffer::RealBuffer(uint8_t* data_, int32_t size_) : data(new uint8_t[size_]), size(size_)
{
memcpy(data, data_, size_);
}
RealBuffer::RealBuffer(RealBuffer const& copy) : data(copy.data), size(copy.size)
{
}
RealBuffer::~RealBuffer()
{
delete[] data;
}
/**
* DBuffer
*/
DBuffer::DBuffer() : __realBuffer(new RealBuffer()) //must not be used
{
}
DBuffer::DBuffer(int32_t size) : __realBuffer(new RealBuffer(size)) //allocate buff for reuse
{
}
DBuffer::DBuffer(uint8_t* data , int32_t size) : __realBuffer(new RealBuffer(data, size))
{
}
DBuffer::DBuffer(DBuffer const& copy) : __realBuffer(copy.__realBuffer)
{
this->__realBuffer->addRef();
}
DBuffer::~DBuffer()
{
this->__realBuffer->destroy();
}
uint8_t* DBuffer::data(void)
{
return (this->__realBuffer->data);
}
int32_t DBuffer::size(void)
{
return (this->__realBuffer->size);
}
}