diff --git a/include/simdjson/inline/parser.h b/include/simdjson/inline/parser.h index 610864c4..76b8d5df 100644 --- a/include/simdjson/inline/parser.h +++ b/include/simdjson/inline/parser.h @@ -158,10 +158,7 @@ inline error_code parser::allocate(size_t capacity, size_t max_depth) noexcept { } if (err) { return err; } - if (implementation->capacity() != capacity || !doc.tape) { - return doc.allocate(capacity); - } - return SUCCESS; + return doc.allocate(capacity); } WARN_UNUSED diff --git a/simdjson-flags.cmake b/simdjson-flags.cmake index af913035..8b490769 100644 --- a/simdjson-flags.cmake +++ b/simdjson-flags.cmake @@ -1,6 +1,31 @@ + +# +# Flags used by exes and by the simdjson library (project-wide flags) +# +add_library(simdjson-flags INTERFACE) +add_library(simdjson-internal-flags INTERFACE) +target_link_libraries(simdjson-internal-flags INTERFACE simdjson-flags) + +option(SIMDJSON_SANITIZE "Sanitize addresses" OFF) +if(SIMDJSON_SANITIZE) + target_compile_options(simdjson-flags INTERFACE -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all) + target_link_libraries(simdjson-flags INTERFACE -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all) + + # Ubuntu bug for GCC 5.0+ (safe for all versions) + if (CMAKE_COMPILER_IS_GNUCC) + target_link_libraries(simdjson-flags INTERFACE -fuse-ld=gold) + endif() +endif() + + if (NOT CMAKE_BUILD_TYPE) - message(STATUS "No build type selected, default to Release") - set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) + if(SIMDJSON_SANITIZE) + message(STATUS "No build type selected, default to Debug since you have actived the sanitizer") + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE) + else() + message(STATUS "No build type selected, default to Release") + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) + endif() endif() if(MSVC) @@ -31,12 +56,6 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) # set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) #endif() -# -# Flags used by exes and by the simdjson library (project-wide flags) -# -add_library(simdjson-flags INTERFACE) -add_library(simdjson-internal-flags INTERFACE) -target_link_libraries(simdjson-internal-flags INTERFACE simdjson-flags) if(MSVC) target_compile_options(simdjson-internal-flags INTERFACE /WX /W3 /sdl) @@ -83,17 +102,6 @@ if(SIMDJSON_ENABLE_THREADS) target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_THREADS_ENABLED=1) endif() -option(SIMDJSON_SANITIZE "Sanitize addresses" OFF) -if(SIMDJSON_SANITIZE) - target_compile_options(simdjson-flags INTERFACE -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all) - target_link_libraries(simdjson-flags INTERFACE -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all) - - # Ubuntu bug for GCC 5.0+ (safe for all versions) - if (CMAKE_COMPILER_IS_GNUCC) - target_link_libraries(simdjson-flags INTERFACE -fuse-ld=gold) - endif() -endif() - if(SIMDJSON_USE_LIBCPP) target_link_libraries(simdjson-flags INTERFACE -stdlib=libc++ -lc++abi) # instead of the above line, we could have used