summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-01-20 16:37:17 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-01-20 16:37:17 +0000
commitce14cf6fb4d97902205107968ed0455784a3a3e7 (patch)
tree6d93a2bd59792d5e4053e351226887c99a5cc1a6 /document
parent543360cbd31917ab0ba71bed0e89ee7b4b1b359c (diff)
32bit size is more than enough here.
Diffstat (limited to 'document')
-rw-r--r--document/src/tests/documenttestcase.cpp2
-rw-r--r--document/src/vespa/document/fieldvalue/serializablearray.cpp2
-rw-r--r--document/src/vespa/document/util/bytebuffer.cpp12
-rw-r--r--document/src/vespa/document/util/bytebuffer.h28
4 files changed, 22 insertions, 22 deletions
diff --git a/document/src/tests/documenttestcase.cpp b/document/src/tests/documenttestcase.cpp
index 4f769841d72..6b33edef18d 100644
--- a/document/src/tests/documenttestcase.cpp
+++ b/document/src/tests/documenttestcase.cpp
@@ -32,7 +32,7 @@ TEST(DocumentTest, testSizeOf)
{
EXPECT_EQ(24u, sizeof(std::vector<char>));
EXPECT_EQ(24u, sizeof(vespalib::alloc::Alloc));
- EXPECT_EQ(48u, sizeof(ByteBuffer));
+ EXPECT_EQ(40u, sizeof(ByteBuffer));
EXPECT_EQ(32u, sizeof(vespalib::GrowableByteBuffer));
EXPECT_EQ(88ul, sizeof(IdString));
EXPECT_EQ(104ul, sizeof(DocumentId));
diff --git a/document/src/vespa/document/fieldvalue/serializablearray.cpp b/document/src/vespa/document/fieldvalue/serializablearray.cpp
index 3887c97bb5e..60ef7c41eb8 100644
--- a/document/src/vespa/document/fieldvalue/serializablearray.cpp
+++ b/document/src/vespa/document/fieldvalue/serializablearray.cpp
@@ -212,7 +212,7 @@ SerializableArray::deCompress() // throw (DeserializeException)
if (unCompressed.getDataLen() != (size_t)_uncompressedLength) {
throw DeserializeException(
- make_string("Did not decompress to the expected length: had %zu, wanted %d, got %zu",
+ make_string("Did not decompress to the expected length: had %u, wanted %d, got %zu",
_compSerData->getRemaining(), _uncompressedLength, unCompressed.getDataLen()),
VESPA_STRLOC);
}
diff --git a/document/src/vespa/document/util/bytebuffer.cpp b/document/src/vespa/document/util/bytebuffer.cpp
index 468f8d653ab..d8572b20eb4 100644
--- a/document/src/vespa/document/util/bytebuffer.cpp
+++ b/document/src/vespa/document/util/bytebuffer.cpp
@@ -61,12 +61,12 @@ BufferOutOfBoundsException::BufferOutOfBoundsException(size_t pos, size_t len, c
{
}
-ByteBuffer::ByteBuffer(size_t len) :
+ByteBuffer::ByteBuffer(uint32_t len) :
ByteBuffer(Alloc::alloc(len), len)
{
}
-ByteBuffer::ByteBuffer(const char* buffer, size_t len) :
+ByteBuffer::ByteBuffer(const char* buffer, uint32_t len) :
_buffer(const_cast<char *>(buffer)),
_len(len),
_pos(0),
@@ -74,7 +74,7 @@ ByteBuffer::ByteBuffer(const char* buffer, size_t len) :
{
}
-ByteBuffer::ByteBuffer(Alloc buffer, size_t len) :
+ByteBuffer::ByteBuffer(Alloc buffer, uint32_t len) :
_buffer(static_cast<char *>(buffer.get())),
_len(len),
_pos(0),
@@ -99,7 +99,7 @@ ByteBuffer::ByteBuffer(const ByteBuffer& rhs) :
ByteBuffer::~ByteBuffer() = default;
-ByteBuffer* ByteBuffer::copyBuffer(const char* buffer, size_t len)
+ByteBuffer* ByteBuffer::copyBuffer(const char* buffer, uint32_t len)
{
if (buffer && len) {
Alloc newBuf = Alloc::alloc(len + 1);
@@ -111,7 +111,7 @@ ByteBuffer* ByteBuffer::copyBuffer(const char* buffer, size_t len)
}
}
-void ByteBuffer::incPos(size_t pos)
+void ByteBuffer::incPos(uint32_t pos)
{
if (_pos + pos > _len) {
throwOutOfBounds(_pos + pos, _len);
@@ -166,7 +166,7 @@ void ByteBuffer::getNumericNetwork(int64_t & v) {
getDoubleLongNetwork(v);
}
-void ByteBuffer::getBytes(void *buffer, size_t count)
+void ByteBuffer::getBytes(void *buffer, uint32_t count)
{
const char *v = getBufferAtPos();
incPos(count);
diff --git a/document/src/vespa/document/util/bytebuffer.h b/document/src/vespa/document/util/bytebuffer.h
index 8f6955966f4..004c88b7f30 100644
--- a/document/src/vespa/document/util/bytebuffer.h
+++ b/document/src/vespa/document/util/bytebuffer.h
@@ -26,12 +26,12 @@ public:
ByteBuffer(const ByteBuffer &);
ByteBuffer& operator=(const ByteBuffer &) = delete;
ByteBuffer(ByteBuffer &&) = default;
- ByteBuffer& operator=(ByteBuffer &&) = default;
+ ByteBuffer& operator=(ByteBuffer &&) = delete;
~ByteBuffer();
/** Allocates buffer with len bytes. */
- ByteBuffer(size_t len);
+ ByteBuffer(uint32_t len);
/**
* Create a buffer with the given content.
@@ -39,7 +39,7 @@ public:
* @param buffer The buffer to represent.
* @param len The length of the buffer
*/
- ByteBuffer(const char* buffer, size_t len);
+ ByteBuffer(const char* buffer, uint32_t len);
/**
* Create a buffer with the given content.
@@ -47,7 +47,7 @@ public:
* @param buffer The buffer to represent.
* @param len The length of the buffer
*/
- ByteBuffer(vespalib::alloc::Alloc buffer, size_t len);
+ ByteBuffer(vespalib::alloc::Alloc buffer, uint32_t len);
/**
* Creates a ByteBuffer object from another buffer. allocates
@@ -59,25 +59,25 @@ public:
* @return Returns a newly created bytebuffer object, or nullptr
* if buffer was nullptr, or len was <=0.
*/
- static ByteBuffer* copyBuffer(const char* buffer, size_t len);
+ static ByteBuffer* copyBuffer(const char* buffer, uint32_t len);
/** @return Returns the buffer pointed to by this object (at position 0) */
const char* getBuffer() const { return _buffer; }
/** @return Returns the length of the buffer pointed to by this object. */
- size_t getLength() const { return _len; }
+ uint32_t getLength() const { return _len; }
/** @return Returns a pointer to the current position in the buffer. */
const char* getBufferAtPos() const { return _buffer + _pos; }
/** @return Returns the index of the current position in the buffer. */
- size_t getPos() const { return _pos; }
+ uint32_t getPos() const { return _pos; }
/**
* @return Returns the number of bytes remaining in the buffer - that is,
* getLimit()-getPos().
*/
- size_t getRemaining() const { return _len -_pos; }
+ uint32_t getRemaining() const { return _len -_pos; }
/**
* Moves the position in the buffer.
@@ -89,7 +89,7 @@ public:
* of the buffer).
* @throws BufferOutOfBoundsException;
*/
- void incPos(size_t pos);
+ void incPos(uint32_t pos);
void getNumeric(uint8_t & v);
void getNumericNetwork(int16_t & v);
@@ -116,17 +116,17 @@ public:
* @return True if all the bytes could be read, false if end of
* buffer is reached
*/
- void getBytes(void *buffer, size_t count);
+ void getBytes(void *buffer, uint32_t count);
private:
template<typename T>
void getDoubleLongNetwork(T &val);
- void incPosNoCheck(size_t pos) { _pos += pos; }
+ void incPosNoCheck(uint32_t pos) { _pos += pos; }
- const char * _buffer;
- const size_t _len;
- size_t _pos;
+ const char * _buffer;
+ const uint32_t _len;
+ uint32_t _pos;
vespalib::alloc::Alloc _ownedBuffer;
};