summaryrefslogtreecommitdiff
path: root/src/KM_platform.h
diff options
context:
space:
mode:
authorjhurst <jhurst@cinecert.com>2021-05-11 14:58:22 -0700
committerjhurst <jhurst@cinecert.com>2021-05-11 14:58:22 -0700
commite5b0a7dbeaaa2b16ea63d7265ed7413f8de2df10 (patch)
tree96cfac1cf70ae0c06bf7e6becc8d0ca9d0214f25 /src/KM_platform.h
parentb14d706a72c706c9c59dbdf64a9e41f32465e060 (diff)
parent3ca74908e673c88ca0ef4350fb74df184aab3332 (diff)
merge origin/master
Diffstat (limited to 'src/KM_platform.h')
-rw-r--r--src/KM_platform.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/KM_platform.h b/src/KM_platform.h
index defcd8a..3e50e54 100644
--- a/src/KM_platform.h
+++ b/src/KM_platform.h
@@ -64,6 +64,7 @@ typedef long long i64_t;
# endif // KM_WIN32
# include <stdio.h>
+# include <string.h>
# include <assert.h>
# include <stdlib.h>
# include <limits.h>
@@ -135,11 +136,17 @@ namespace Kumu
// read an integer from byte-structured storage
template<class T>
- inline T cp2i(const byte_t* p) { return *(T*)p; }
+ inline T cp2i(const byte_t* p) {
+ T value;
+ memcpy(&value, p, sizeof(T));
+ return value;
+ }
// write an integer to byte-structured storage
template<class T>
- inline void i2p(T i, byte_t* p) { *(T*)p = i; }
+ inline void i2p(T i, byte_t* p) {
+ memcpy(p, &i, sizeof(T));
+ }
# ifdef KM_BIG_ENDIAN