Skip to content

Commit

Permalink
[fold] Replace memcpy with std::memcpy
Browse files Browse the repository at this point in the history
  • Loading branch information
seelabs committed May 22, 2023
1 parent 1acc8bc commit a553a13
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/ripple/basics/SlabAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class SlabAllocator
{
// Use memcpy to avoid unaligned UB
// (will optimize to equivalent code)
memcpy(data, &l_, sizeof(std::uint8_t*));
std::memcpy(data, &l_, sizeof(std::uint8_t*));
l_ = data;
data += item;
}
Expand Down Expand Up @@ -122,7 +122,7 @@ class SlabAllocator
{
// Use memcpy to avoid unaligned UB
// (will optimize to equivalent code)
memcpy(&l_, ret, sizeof(std::uint8_t*));
std::memcpy(&l_, ret, sizeof(std::uint8_t*));
}
}

Expand All @@ -147,7 +147,7 @@ class SlabAllocator

// Use memcpy to avoid unaligned UB
// (will optimize to equivalent code)
memcpy(ptr, &l_, sizeof(std::uint8_t*));
std::memcpy(ptr, &l_, sizeof(std::uint8_t*));
l_ = ptr;
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/basics/impl/partitioned_unordered_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extract(uint256 const& key)
std::size_t result;
// Use memcpy to avoid unaligned UB
// (will optimize to equivalent code)
memcpy(&result, key.data(), sizeof(std::size_t));
std::memcpy(&result, key.data(), sizeof(std::size_t));
return result;
}

Expand Down
6 changes: 4 additions & 2 deletions src/ripple/beast/hash/impl/xxhash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ You can contact the author at :

#include <ripple/beast/hash/impl/xxhash.h>

#include <cstring>

//**************************************
// Tuning parameters
//**************************************
Expand Down Expand Up @@ -87,7 +89,7 @@ You can contact the author at :
//**************************************
// Includes & Memory related functions
//**************************************
//#include "xxhash.h"
// #include "xxhash.h"
// Modify the local functions below should you wish to use some other memory
// routines for malloc(), free()
#include <stdlib.h>
Expand Down Expand Up @@ -263,7 +265,7 @@ XXH_readLE64_align(const void* ptr, XXH_endianess endian, XXH_alignment align)
{
// Use memcpy to avoid unaligned UB
U64 tmp_aligned;
memcpy(&tmp_aligned, ptr, sizeof(U64));
std::memcpy(&tmp_aligned, ptr, sizeof(U64));
return endian == XXH_littleEndian ? tmp_aligned
: XXH_swap64(tmp_aligned);
}
Expand Down

0 comments on commit a553a13

Please sign in to comment.