Replaced BOOST_FOREACH with C++11 range-based for loops
[pulseview.git] / pv / data / logicsnapshot.cpp
index a1beafb9c4e4e3e3c50a111077e62fd3c2d261d5..f896ed178718dd2dc6f840c6567dcba15c4220e2 100644 (file)
@@ -25,8 +25,7 @@
 #include <stdlib.h>
 #include <math.h>
 
-#include <boost/foreach.hpp>
-
+#include "config.h"
 #include "logicsnapshot.h"
 
 using boost::lock_guard;
@@ -58,12 +57,15 @@ LogicSnapshot::LogicSnapshot(const sr_datafeed_logic &logic,
 LogicSnapshot::~LogicSnapshot()
 {
        lock_guard<recursive_mutex> lock(_mutex);
-       BOOST_FOREACH(MipMapLevel &l, _mip_map)
+       for (MipMapLevel &l : _mip_map)
                free(l.data);
 }
 
 uint64_t LogicSnapshot::unpack_sample(const uint8_t *ptr) const
 {
+#ifdef HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS
+       return *(uint64_t*)ptr;
+#else
        uint64_t value = 0;
        switch(_unit_size) {
        default:
@@ -94,10 +96,14 @@ uint64_t LogicSnapshot::unpack_sample(const uint8_t *ptr) const
                break;
        }
        return value;
+#endif
 }
 
 void LogicSnapshot::pack_sample(uint8_t *ptr, uint64_t value)
 {
+#ifdef HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS
+       *(uint64_t*)ptr = value;
+#else
        switch(_unit_size) {
        default:
                ptr[7] = value >> 56;
@@ -126,6 +132,7 @@ void LogicSnapshot::pack_sample(uint8_t *ptr, uint64_t value)
        case 0:
                break;
        }
+#endif
 }
 
 void LogicSnapshot::append_payload(
@@ -155,7 +162,7 @@ void LogicSnapshot::get_samples(uint8_t *const data,
        lock_guard<recursive_mutex> lock(_mutex);
 
        const size_t size = (end_sample - start_sample) * _unit_size;
-       memcpy(data, (const uint8_t*)_data + start_sample, size);
+       memcpy(data, (const uint8_t*)_data + start_sample * _unit_size, size);
 }
 
 void LogicSnapshot::reallocate_mipmap_level(MipMapLevel &m)