diff options
author | Alan Conway <aconway@apache.org> | 2008-11-12 17:15:20 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2008-11-12 17:15:20 +0000 |
commit | c99d4d45ead8020517838b99e2106887701b17d7 (patch) | |
tree | 66559a3df444de8a4cb52ffbead0123dd2325d69 /cpp/src/qpid/framing/Buffer.cpp | |
parent | 1a18c1798833e7201177e786afa0d05412c4f53b (diff) | |
download | qpid-python-c99d4d45ead8020517838b99e2106887701b17d7.tar.gz |
Cluster replicates queues/exchanges with same encode/decode functions as the store.
Removed un-necessary heap allocation in QPID_LOG statements.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@713425 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/framing/Buffer.cpp')
-rw-r--r-- | cpp/src/qpid/framing/Buffer.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/cpp/src/qpid/framing/Buffer.cpp b/cpp/src/qpid/framing/Buffer.cpp index 459aa3881b..a90c3a2e64 100644 --- a/cpp/src/qpid/framing/Buffer.cpp +++ b/cpp/src/qpid/framing/Buffer.cpp @@ -51,12 +51,14 @@ void Buffer::reset(){ void Buffer::putOctet(uint8_t i){ data[position++] = i; + assert(position <= size); } void Buffer::putShort(uint16_t i){ uint16_t b = i; data[position++] = (uint8_t) (0xFF & (b >> 8)); data[position++] = (uint8_t) (0xFF & b); + assert(position <= size); } void Buffer::putLong(uint32_t i){ @@ -65,6 +67,7 @@ void Buffer::putLong(uint32_t i){ data[position++] = (uint8_t) (0xFF & (b >> 16)); data[position++] = (uint8_t) (0xFF & (b >> 8)); data[position++] = (uint8_t) (0xFF & b); + assert(position <= size); } void Buffer::putLongLong(uint64_t i){ @@ -76,6 +79,7 @@ void Buffer::putLongLong(uint64_t i){ void Buffer::putInt8(int8_t i){ data[position++] = (uint8_t) i; + assert(position <= size); } void Buffer::putInt16(int16_t i){ @@ -116,13 +120,16 @@ void Buffer::putBin128(uint8_t* b){ } uint8_t Buffer::getOctet(){ - return (uint8_t) data[position++]; + uint8_t octet = static_cast<uint8_t>(data[position++]); + assert(position <= size); + return octet; } uint16_t Buffer::getShort(){ uint16_t hi = (unsigned char) data[position++]; hi = hi << 8; hi |= (unsigned char) data[position++]; + assert(position <= size); return hi; } @@ -131,6 +138,7 @@ uint32_t Buffer::getLong(){ uint32_t b = (unsigned char) data[position++]; uint32_t c = (unsigned char) data[position++]; uint32_t d = (unsigned char) data[position++]; + assert(position <= size); a = a << 24; a |= b << 16; a |= c << 8; @@ -146,7 +154,9 @@ uint64_t Buffer::getLongLong(){ } int8_t Buffer::getInt8(){ - return (int8_t) data[position++]; + int8_t i = static_cast<int8_t>(data[position++]); + assert(position <= size); + return i; } int16_t Buffer::getInt16(){ |