qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r1511013 - /qpid/trunk/qpid/cpp/src/qpid/broker/PagedQueue.cpp
Date Tue, 06 Aug 2013 15:58:07 GMT
Author: gsim
Date: Tue Aug  6 15:58:06 2013
New Revision: 1511013

URL: http://svn.apache.org/r1511013
Log:
QPID-5042: use more protable encode and decode

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/PagedQueue.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/PagedQueue.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/PagedQueue.cpp?rev=1511013&r1=1511012&r2=1511013&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/PagedQueue.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/PagedQueue.cpp Tue Aug  6 15:58:06 2013
@@ -295,7 +295,8 @@ void PagedQueue::Page::load(MemoryMapped
     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(MemoryMapp
         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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message