aboutsummaryrefslogtreecommitdiff
path: root/ble/ByteBuffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ble/ByteBuffer.cpp')
-rw-r--r--ble/ByteBuffer.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/ble/ByteBuffer.cpp b/ble/ByteBuffer.cpp
index 1a294f1..40ba06c 100644
--- a/ble/ByteBuffer.cpp
+++ b/ble/ByteBuffer.cpp
@@ -7,13 +7,8 @@
#include <iostream>
#include <ble/ByteBuffer.h>
-
using namespace std;
-ByteBuffer ByteBuffer::alloc(std::size_t size) {
- return {new uint8_t[size], size};
-}
-
ByteBuffer::ByteBuffer(uint8_t* bytes, size_t size) :
zero(bytes), end_(&bytes[size]), cursor(bytes) {
}
@@ -47,7 +42,7 @@ ByteBuffer &ByteBuffer::write(const ByteBuffer &value) {
ByteBuffer &ByteBuffer::write(const uint8_t *bytes, size_t len) {
assertCanAccessRelative(len);
- memcpy(cursor, bytes, len);
+ std::memcpy(cursor, bytes, len);
cursor += len;
@@ -174,7 +169,13 @@ double ByteBuffer::readFLOAT() {
void ByteBuffer::copy(uint8_t *bytes, size_t length) const {
assertCanAccessRelative(length - 1);
- memcpy(bytes, cursor, length);
+ std::memcpy(bytes, cursor, length);
+}
+
+void ByteBuffer::copy(ByteBuffer& other) const {
+ other.assertCanAccessRelative(getBytesLeft());
+
+ std::memcpy(other.cursor, cursor, getBytesLeft());
}
void ByteBuffer::reset() {
@@ -182,7 +183,7 @@ void ByteBuffer::reset() {
}
ByteBuffer ByteBuffer::view() const {
-// DF << "cursor=" << getCursor() << ", size=" << getSize() << ", new size=" << end_ - cursor << ", cursor=" << (uint64_t) cursor << ", zero=" << (uint64_t) zero;
+// LOG_DEBUG("cursor=" << getCursor() << ", size=" << getSize() << ", new size=" << end_ - cursor << ", cursor=" << (uint64_t) cursor << ", zero=" << (uint64_t) zero);
return {cursor, getBytesLeft()};
}