Skip to content

Commit

Permalink
Fix c++20 compilation problem for clang10 and fix potential bug due t…
Browse files Browse the repository at this point in the history
…o compiler optimization
  • Loading branch information
Christian Ledergerber authored and BillyDonahue committed Nov 2, 2020
1 parent 5f4e104 commit 30170d6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions include/json/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ template <typename T> class SecureAllocator {
* Release memory which was allocated for N items at pointer P.
*
* The memory block is filled with zeroes before being released.
* The pointer argument is tagged as "volatile" to prevent the
* compiler optimizing out this critical step.
*/
void deallocate(volatile pointer p, size_type n) {
std::memset(p, 0, n * sizeof(T));
void deallocate(pointer p, size_type n) {
// memset_s is used because memset may be optimized away by the compiler
memset_s(p, n * sizeof(T), 0, n * sizeof(T));
// free using "global operator delete"
::operator delete(p);
}
Expand Down

0 comments on commit 30170d6

Please sign in to comment.