diff options
author | Jack Lloyd <[email protected]> | 2019-01-31 18:04:53 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-01-31 18:04:53 -0500 |
commit | 31e560cf01781cc4537748e4e28b525f25abe29f (patch) | |
tree | 1b234c4e692e5ecb34140cc821a5d63afbb5c18c /src/lib | |
parent | 85321dbcc0ca97846213ef6eb245c3e1159078e2 (diff) |
Have set_mem only work for bytes
It is (mildly) dangerous with larger types, and we don't need it.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/utils/mem_ops.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lib/utils/mem_ops.h b/src/lib/utils/mem_ops.h index bff15e98a..31a1efcc9 100644 --- a/src/lib/utils/mem_ops.h +++ b/src/lib/utils/mem_ops.h @@ -144,16 +144,15 @@ template<typename T> inline void typecast_copy(T out[], const uint8_t in[], size /** * Set memory to a fixed value -* @param ptr a pointer to an array +* @param ptr a pointer to an array of bytes * @param n the number of Ts pointed to by ptr * @param val the value to set each byte to */ -template<typename T> -inline void set_mem(T* ptr, size_t n, uint8_t val) +inline void set_mem(uint8_t* ptr, size_t n, uint8_t val) { if(n > 0) { - std::memset(ptr, val, sizeof(T)*n); + std::memset(ptr, val, n); } } |