CMakeLists: fix optflags for ppc
Unbreak ppc :)
snprintf
is C++11 so it cannot pass CI.
避免 malloc()
/free()
,这里似乎用 PUTC()
就 OK。
如果真想写成数组,声明为 char ch[2]
,然后宏里面也可以用 sizeof(ch)
( == 2
)。
Use passed in allocator.
The Schema class here allows a user to provide a custom allocator which I believe should be used here instead of the default CrtAllocator. This would be kind of problematic in cases like a client provides an allocator that throws on memory allocation error since the default CrtAllocator does not throw.
Rather:
std::string stringify(const rapidjson::Value& v) { if (v.IsString()) return { v.GetString(), v.GetStringLength() }; else { rapidjson::StringBuffer strbuf; rapidjson::Writer<rapidjson::StringBuffer> writer(strbuf); v.Accept(writer); return { strbuf.GetString(), strbuf.GetLength() }; } }
Faster and will also prevent quotes around from being added if the value is already a string.
JSON and JSON string value are two different concepts. Just returning the string value is not "stringifying a JSON".
fix #1
Suppress uritest
This PR is intended to address the SIMD unit test sanitizer problem identified in issue #2019, and any other sanitizer problems that are being thrown up when running other RapidJSON unit tests under valgrind
. #2019 contains the list but in summary:
I am seeing all these on master
branch (Fedora 36).
I am unsure about the suppression situation. Adding alignment to input buffer in this PR should help. But not sure if it can fix all valgrind problems. If this PR can improve some situations that you encountered, I think we may merge it first.
fix a typo in error.h: literial -> literal
#2109
In /include/rapidjson/error/error.h
A small typo: literial
-> literal