Fix for issues 32, 50, 131, 137

* Improving portability.

* Revisiting faulty logic regarding same-page overruns.

* Disabling same-page overruns under VS.

* Clarifying the documentation

* Fix for issue 131 + being more explicit regarding memory realloc.

* Fix for issue 137.

* removing "using namespace std" throughout. Fix for 50

* Introducing typed malloc/free.

* Introducing a custom class (padded_string) that solves several minor usability issues.

* Updating amalgamation for testing.
This commit is contained in:
Daniel Lemire
2019-05-09 17:59:51 -04:00
committed by GitHub
parent c5a3f9ccd4
commit e370a65383
31 changed files with 1109 additions and 366 deletions
+5 -8
View File
@@ -3,8 +3,6 @@
#include "simdjson/jsonioutil.h"
#include "simdjson/jsonparser.h"
using namespace std;
size_t count_nonasciibytes(const uint8_t* input, size_t length) {
size_t count = 0;
for(size_t i = 0; i < length; i++) {
@@ -43,7 +41,7 @@ using stat_t = struct stat_s;
stat_t simdjson_computestats(const std::string_view &p) {
stat_t simdjson_computestats(const padded_string &p) {
stat_t answer;
ParsedJson pj = build_parsed_json(p);
answer.valid = pj.isValid();
@@ -119,18 +117,17 @@ stat_t simdjson_computestats(const std::string_view &p) {
int main(int argc, char *argv[]) {
int optind = 1;
if (optind >= argc) {
cerr << "Reads json, prints stats. " << endl;
cerr << "Usage: " << argv[0] << " <jsonfile>" << endl;
std::cerr << "Reads json, prints stats. " << std::endl;
std::cerr << "Usage: " << argv[0] << " <jsonfile>" << std::endl;
exit(1);
}
const char *filename = argv[optind];
if (optind + 1 < argc) {
std::cerr << "warning: ignoring everything after " << argv[optind + 1] << std::endl;
}
std::string_view p;
padded_string p;
try {
p = get_corpus(filename);
get_corpus(filename).swap(p);
} catch (const std::exception &e) { // caught by reference to base
std::cerr << "Could not load the file " << filename << std::endl;
return EXIT_FAILURE;