From 40a5d5ddfa2ce7e37415ceed3e02d8b2f73bfd80 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Fri, 15 Mar 2019 12:11:50 -0400 Subject: [PATCH] Being explicit about aligned_free --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8c59e627e..94ac21686 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Under Windows, we build some tools using the windows/dirent_portable.h file (whi const char * filename = ... // // use whatever means you want to get a string of your JSON document -std::string_view p = get_corpus(filename); +std::string_view p = get_corpus(filename); // you are responsible for freeing p.data() ParsedJson pj; pj.allocateCapacity(p.size()); // allocate memory for parsing up to p.size() bytes const int res = json_parse(p, pj); // do the parsing, return 0 on success @@ -71,7 +71,7 @@ if (res != 0) { std::cout << "Error parsing:" << simdjson::errorMsg(res) << std::endl; } // You can safely delete the string content -free((void*)p.data()); +aligned_free((void*)p.data()); // the ParsedJson document can be used here // js can be reused with other json_parse calls. ``` @@ -91,6 +91,7 @@ ParsedJson pj = build_parsed_json(p); // do the parsing if( ! pj.isValid() ) { // something went wrong } +aligned_free((void*)p.data()); ``` ## Usage: easy single-header version @@ -112,6 +113,7 @@ int main(int argc, char *argv[]) { } else { std::cout << "valid" << std::endl; } + aligned_free((void*)p.data()); return EXIT_SUCCESS; } ```