Minor source reorganization; few dangerous C functions replaced with safer std:: alternatives

This commit is contained in:
Pavel Kirienko
2014-02-01 19:00:05 +04:00
parent b385ffb12e
commit 00b977eb40
9 changed files with 43 additions and 40 deletions
+4 -4
View File
@@ -7,7 +7,7 @@
#include <cassert>
#include <stdint.h>
#include <cstring>
#include <algorithm>
#include <string>
namespace uavcan
@@ -31,7 +31,7 @@ struct CanFrame
: id(0)
, dlc(0)
{
std::memset(data, 0, sizeof(data));
std::fill(data, data + sizeof(data), 0);
}
CanFrame(uint32_t id, const uint8_t* data, unsigned int dlc)
@@ -39,13 +39,13 @@ struct CanFrame
, dlc(dlc)
{
assert(data && dlc <= 8);
std::memmove(this->data, data, dlc);
std::copy(data, data + dlc, this->data);
}
bool operator!=(const CanFrame& rhs) const { return !operator==(rhs); }
bool operator==(const CanFrame& rhs) const
{
return (id == rhs.id) && (dlc == rhs.dlc) && (memcmp(data, rhs.data, dlc) == 0);
return (id == rhs.id) && (dlc == rhs.dlc) && std::equal(data, data + dlc, rhs.data);
}
bool isExtended() const { return id & FLAG_EFF; }
@@ -6,7 +6,6 @@
#pragma once
#include <cassert>
#include <cstring>
#include <stdint.h>
#include <uavcan/internal/linked_list.hpp>
#include <uavcan/internal/dynamic_memory.hpp>
@@ -18,6 +18,8 @@ namespace uavcan
class ISystemClock
{
public:
virtual ~ISystemClock() { }
/**
* Monototic system clock in microseconds.
* This shall never jump during UTC timestamp adjustments; the base time is irrelevant.