diff options
Diffstat (limited to 'src/common/utils.hpp')
-rw-r--r-- | src/common/utils.hpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/common/utils.hpp b/src/common/utils.hpp index cd45aa1..ab32948 100644 --- a/src/common/utils.hpp +++ b/src/common/utils.hpp @@ -34,7 +34,8 @@ void strzcpy(char *dest, const char *src, size_t n) { if (n) { - strncpy(dest, src, n); + // hmph + strncpy(dest, src, n - 1); dest[n - 1] = '\0'; } } @@ -50,6 +51,11 @@ void really_memmove(uint8_t *dest, const uint8_t *src, size_t n) { memmove(dest, src, n); } +inline +bool really_memequal(const uint8_t *a, const uint8_t *b, size_t n) +{ + return memcmp(a, b, n) == 0; +} inline void really_memset0(uint8_t *dest, size_t n) @@ -140,4 +146,10 @@ static_assert(sizeof(TIMESTAMP_DUMMY) == sizeof(timestamp_seconds_buffer), &t \ ) +template<class T> +const T& const_(T& t) +{ + return t; +} + #endif //UTILS_HPP |