diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-03-06 22:53:36 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-03-06 22:53:36 +0100 |
commit | 56dfbcd73529ee6dc42a17a139c9ceaccf1def3d (patch) | |
tree | 47580fcfa894fca04805f670ec6acf30a08a6f5d /src/Buffer.h | |
parent | 5bea9241b246cfc4b9abef3d265a96d52a377c37 (diff) | |
download | dabmod-56dfbcd73529ee6dc42a17a139c9ceaccf1def3d.tar.gz dabmod-56dfbcd73529ee6dc42a17a139c9ceaccf1def3d.tar.bz2 dabmod-56dfbcd73529ee6dc42a17a139c9ceaccf1def3d.zip |
Avoid copies in ThreadsafeQueue and Buffer
Diffstat (limited to 'src/Buffer.h')
-rw-r--r-- | src/Buffer.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Buffer.h b/src/Buffer.h index e486724..d181a46 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -50,6 +50,8 @@ class Buffer { Buffer(const std::vector<uint8_t>& vec); ~Buffer(); + void swap(Buffer& other); + /* Resize the buffer, reallocate memory if needed */ void setLength(size_t len); @@ -60,6 +62,8 @@ class Buffer { Buffer& operator=(Buffer&& other); Buffer& operator=(const std::vector<uint8_t>& buf); + uint8_t operator[](size_t i) const; + /* Concatenate the current data with the new data given. * Reallocates memory if needed. */ void appendData(const void *data, size_t len); @@ -80,3 +84,5 @@ class Buffer { void *m_data; }; +void swap(Buffer& buf1, Buffer& buf2); + |