summaryrefslogtreecommitdiff
path: root/qpid/cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2013-08-06 15:58:06 +0000
committerGordon Sim <gsim@apache.org>2013-08-06 15:58:06 +0000
commitf6ab4d61d4387316226092d7c963c9543ffaf9e3 (patch)
treebe5dc0de46c2099fa87431391752390b9c469b4f /qpid/cpp
parentbb26d120c04ff853238562e404de15f2b3c74652 (diff)
downloadqpid-python-f6ab4d61d4387316226092d7c963c9543ffaf9e3.tar.gz
QPID-5042: use more protable encode and decode
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1511013 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp')
-rw-r--r--qpid/cpp/src/qpid/broker/PagedQueue.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/qpid/cpp/src/qpid/broker/PagedQueue.cpp b/qpid/cpp/src/qpid/broker/PagedQueue.cpp
index 9bce28061a..e11be471c0 100644
--- a/qpid/cpp/src/qpid/broker/PagedQueue.cpp
+++ b/qpid/cpp/src/qpid/broker/PagedQueue.cpp
@@ -295,7 +295,8 @@ void PagedQueue::Page::load(MemoryMappedFile& file, ProtocolRegistry& protocols)
bool haveData = used > 0;
used = 4;//first 4 bytes are the count
if (haveData) {
- uint32_t count = *(reinterpret_cast<uint32_t*>(region));
+ qpid::framing::Buffer buffer(region, sizeof(uint32_t));
+ uint32_t count = buffer.getLong();
//decode messages into Page::messages
for (size_t i = 0; i < count; ++i) {
Message message;
@@ -331,7 +332,8 @@ void PagedQueue::Page::unload(MemoryMappedFile& file)
if (i->getState() == ACQUIRED) acquired.add(i->getSequence());
}
uint32_t count = messages.size();
- ::memcpy(region, &count, sizeof(count));
+ qpid::framing::Buffer buffer(region, sizeof(uint32_t));
+ buffer.putLong(count);
file.flush(region, size);
file.unmap(region, size);
//remove messages from memory