File tree 2 files changed +8
-5
lines changed
samples/opensource/sampleUffPluginV2Ext
2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 19
19
#include " checkMacrosPlugin.h"
20
20
21
21
#include " NvInferPlugin.h"
22
+ #include < cstring>
22
23
#include < cuda_runtime.h>
23
24
#include < iostream>
24
25
#include < memory>
@@ -78,15 +79,16 @@ class BaseCreator : public IPluginCreator
78
79
template <typename T>
79
80
void write (char *& buffer, const T& val)
80
81
{
81
- * reinterpret_cast <T*> (buffer) = val;
82
+ std::memcpy (buffer, & val, sizeof (T)) ;
82
83
buffer += sizeof (T);
83
84
}
84
85
85
86
// Read values from buffer
86
87
template <typename T>
87
88
T read (const char *& buffer)
88
89
{
89
- T val = *reinterpret_cast <const T*>(buffer);
90
+ T val;
91
+ std::memcpy (&val, buffer, sizeof (T));
90
92
buffer += sizeof (T);
91
93
return val;
92
94
}
Original file line number Diff line number Diff line change 18
18
#include " NvUffParser.h"
19
19
#include < cassert>
20
20
#include < chrono>
21
+ #include < cstring>
21
22
#include < cudnn.h>
22
23
#include < iostream>
23
24
#include < map>
24
- #include < string.h>
25
25
#include < unordered_map>
26
26
#include < vector>
27
27
@@ -579,14 +579,15 @@ class UffPoolPluginV2 : public IPluginV2IOExt
579
579
template <typename T>
580
580
void write (char *& buffer, const T& val) const
581
581
{
582
- * reinterpret_cast <T*> (buffer) = val;
582
+ std::memcpy (buffer, & val, sizeof (T)) ;
583
583
buffer += sizeof (T);
584
584
}
585
585
586
586
template <typename T>
587
587
T read (const char *& buffer) const
588
588
{
589
- T val = *reinterpret_cast <const T*>(buffer);
589
+ T val;
590
+ std::memcpy (&val, buffer, sizeof (T));
590
591
buffer += sizeof (T);
591
592
return val;
592
593
}
You can’t perform that action at this time.
0 commit comments