Skip to content

Commit

Permalink
Update jsoncpp copy to 1.9.6
Browse files Browse the repository at this point in the history
note: the version number is different due to open-source-parsers/jsoncpp#1571
  • Loading branch information
sfan5 committed Oct 13, 2024
1 parent cbc741f commit dbbe0ca
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 146 deletions.
2 changes: 1 addition & 1 deletion lib/jsoncpp/json/UPDATING
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
cd ..
git clone https://github.com/open-source-parsers/jsoncpp -b 1.9.5 --depth 1
git clone https://github.com/open-source-parsers/jsoncpp -b 1.9.6 --depth 1
cd jsoncpp
./amalgamate.py
cp -R dist/json ../json
Expand Down
31 changes: 21 additions & 10 deletions lib/jsoncpp/json/json-forwards.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// Json-cpp amalgamated forward header (http://jsoncpp.sourceforge.net/).
/// Json-cpp amalgamated forward header (https://github.com/open-source-parsers/jsoncpp/).
/// It is intended to be used with #include "json/json-forwards.h"
/// This header provides forward declaration for all JsonCpp types.

Expand Down Expand Up @@ -94,19 +94,18 @@ license you like.
// 3. /CMakeLists.txt
// IMPORTANT: also update the SOVERSION!!

#define JSONCPP_VERSION_STRING "1.9.5"
#define JSONCPP_VERSION_STRING "1.9.7"
#define JSONCPP_VERSION_MAJOR 1
#define JSONCPP_VERSION_MINOR 9
#define JSONCPP_VERSION_PATCH 5
#define JSONCPP_VERSION_PATCH 7
#define JSONCPP_VERSION_QUALIFIER
#define JSONCPP_VERSION_HEXA \
((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \
(JSONCPP_VERSION_PATCH << 8))

#ifdef JSONCPP_USING_SECURE_MEMORY
#undef JSONCPP_USING_SECURE_MEMORY
#if !defined(JSONCPP_USE_SECURE_MEMORY)
#define JSONCPP_USE_SECURE_MEMORY 0
#endif
#define JSONCPP_USING_SECURE_MEMORY 0
// If non-zero, the library zeroes any memory that it has allocated before
// it frees its memory.

Expand All @@ -133,10 +132,12 @@ license you like.
#ifndef JSON_ALLOCATOR_H_INCLUDED
#define JSON_ALLOCATOR_H_INCLUDED

#include <algorithm>
#include <cstring>
#include <memory>

#pragma pack(push, 8)
#pragma pack(push)
#pragma pack()

namespace Json {
template <typename T> class SecureAllocator {
Expand Down Expand Up @@ -164,8 +165,16 @@ template <typename T> class SecureAllocator {
* The memory block is filled with zeroes before being released.
*/
void deallocate(pointer p, size_type n) {
// memset_s is used because memset may be optimized away by the compiler
// These constructs will not be removed by the compiler during optimization,
// unlike memset.
#if defined(HAVE_MEMSET_S)
memset_s(p, n * sizeof(T), 0, n * sizeof(T));
#elif defined(_WIN32)
RtlSecureZeroMemory(p, n * sizeof(T));
#else
std::fill_n(reinterpret_cast<volatile unsigned char*>(p), n, 0);
#endif

// free using "global operator delete"
::operator delete(p);
}
Expand Down Expand Up @@ -195,7 +204,9 @@ template <typename T> class SecureAllocator {
// Boilerplate
SecureAllocator() {}
template <typename U> SecureAllocator(const SecureAllocator<U>&) {}
template <typename U> struct rebind { using other = SecureAllocator<U>; };
template <typename U> struct rebind {
using other = SecureAllocator<U>;
};
};

template <typename T, typename U>
Expand Down Expand Up @@ -356,7 +367,7 @@ using LargestUInt = UInt64;

template <typename T>
using Allocator =
typename std::conditional<JSONCPP_USING_SECURE_MEMORY, SecureAllocator<T>,
typename std::conditional<JSONCPP_USE_SECURE_MEMORY, SecureAllocator<T>,
std::allocator<T>>::type;
using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
using IStringStream =
Expand Down
Loading

0 comments on commit dbbe0ca

Please sign in to comment.