11#include " ByteBuffer.h"
22#include < iostream>
33
4-
5- ByteBuffer::ByteBuffer (BYTE *v_content, bufsize_t v_size, bufsize_t v_padding)
6- : content(nullptr ), contentSize(0 ), padding(v_padding),
7- originalSize(0 )
4+ ByteBuffer::ByteBuffer (bufsize_t v_size, bufsize_t v_padding)
5+ : ByteBuffer()
86{
97 if (v_size == 0 ) throw BufferException (" Zero size requested" );
108
119 this ->content = allocContent (v_size, v_padding);
12- if (this ->content ) {
10+ if (this ->content ) {
11+ this ->padding = v_padding;
1312 this ->contentSize = v_size;
1413 this ->originalSize = v_size;
15- if (v_content) {
16- ::memcpy (this ->content, v_content, v_size);
17- }
18- }
14+ }
1915}
2016
21- ByteBuffer::ByteBuffer (bufsize_t v_size, bufsize_t v_padding)
22- : ByteBuffer(nullptr , v_size, v_padding)
17+ ByteBuffer::ByteBuffer (BYTE* v_content, bufsize_t v_size, bufsize_t v_padding)
18+ : ByteBuffer(v_size, v_padding)
2319{
20+ if (v_size == 0 ) throw BufferException (" Zero size requested" );
21+ if (this ->content && v_content) {
22+ ::memcpy (this ->content, v_content, v_size);
23+ }
2424}
2525
2626ByteBuffer::ByteBuffer (AbstractByteBuffer *v_parent, offset_t v_offset, bufsize_t v_size, bufsize_t v_padding)
27- : content(nullptr ), contentSize(0 ), padding(0 ),
28- originalSize(0 )
27+ : ByteBuffer()
2928{
3029 if (!v_parent) throw BufferException (" Cannot make subBuffer for NULL buffer!" );
3130 if (!v_size) throw BufferException (" Cannot make 0 size buffer!" );
@@ -40,6 +39,7 @@ ByteBuffer::ByteBuffer(AbstractByteBuffer *v_parent, offset_t v_offset, bufsize_
4039
4140 this ->content = allocContent (allocSize, v_padding);
4241 if (this ->content ) {
42+ this ->padding = v_padding;
4343 this ->contentSize = allocSize;
4444 this ->originalSize = this ->contentSize ;
4545 ::memcpy (this ->content, bContent, copySize);
0 commit comments