Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lang/c++/include/avro/buffer/BufferReader.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define avro_BufferReader_hh__

#include "Buffer.hh"
#include <cstring>
#include <type_traits>

#ifdef min
Expand Down Expand Up @@ -233,7 +234,7 @@ private:
}

if (sizeof(T) <= chunkRemaining()) {
val = *(reinterpret_cast<const T *>(addr()));
memcpy(&val, addr(), sizeof(T));
incrementChunk(sizeof(T));
} else {
read(reinterpret_cast<data_type *>(&val), sizeof(T));
Expand Down
3 changes: 2 additions & 1 deletion lang/c++/include/avro/buffer/detail/BufferDetail.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define avro_BufferDetail_hh__

#include <cassert>
#include <cstring>
#include <deque>
#include <exception>
#include <functional>
Expand Down Expand Up @@ -320,7 +321,7 @@ public:
if (freeSpace_ && (sizeof(T) <= writeChunks_.front().freeSize())) {
// fast path, there's enough room in the writeable chunk to just
// straight out copy it
*(reinterpret_cast<T *>(writeChunks_.front().tellWritePos())) = val;
memcpy(writeChunks_.front().tellWritePos(), &val, sizeof(T));
Comment thread
apilloud marked this conversation as resolved.
postWrite(sizeof(T));
} else {
// need to fixup chunks first, so use the regular memcpy
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the else clause the comment mentions memcpy but still uses reinterpret_cast.

I am not C++ dev, so I don't know whether this needs fixing or not.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expand Down
Loading