From 0133fb0fc07449293fe5e5dca71f3a61ca29b161 Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Tue, 10 May 2016 10:51:59 -0400 Subject: [PATCH] fixing bots --- build/CMakeLists.txt | 12 +++++++++--- src/nstore.cpp | 18 ++++++++---------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index f5c1de65..e74eb07b 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -14,8 +14,12 @@ if(${CMAKE_BUILD_TYPE}) endif() find_package(Boost 1.55 REQUIRED - COMPONENTS iostreams serialization unit_test_framework) -find_library(Boost_PYTHON_FOUND boost_python) # optional + COMPONENTS iostreams serialization unit_test_framework python) +if(NOT ${Boost_FOUND}) + # try again without boost.python + find_package(Boost 1.55 REQUIRED + COMPONENTS iostreams serialization unit_test_framework) +endif() add_definitions(-DBOOST_TEST_DYN_LINK) # for unit_test_framework add_definitions(-Wall) @@ -58,6 +62,8 @@ if(USE_PYTHON AND Boost_PYTHON_FOUND) # Python3 is currently not supported set(HAVE_PYTHON 1) + message(STATUS "Python version: ${PYTHON_VERSION}") + include_directories(${PYTHON_INCLUDE_DIRS}) if(${PYTHON_VERSION} VERSION_GREATER 3.0) @@ -80,7 +86,7 @@ if(USE_PYTHON AND Boost_PYTHON_FOUND) ../src/python/basic_histogram.cpp ../src/python/histogram.cpp ) - target_link_libraries(pyhistogram boost_histogram ${LIBRARIES} boost_python ${PYTHON_LIBRARIES}) + target_link_libraries(pyhistogram boost_histogram ${LIBRARIES} ${PYTHON_LIBRARIES}) set_target_properties(pyhistogram PROPERTIES OUTPUT_NAME "histogram" PREFIX "" SUFFIX ".so") endif() endif() diff --git a/src/nstore.cpp b/src/nstore.cpp index b10aef48..7bc5d6e5 100644 --- a/src/nstore.cpp +++ b/src/nstore.cpp @@ -136,22 +136,20 @@ void nstore::grow() { BOOST_ASSERT(size_ > 0); - if (depth_ == 0) { - depth_ = sizeof(uint8_t); - create(0); - return; - } - // realloc is safe if buffer_ is null - buffer_ = std::realloc(buffer_, size_ * 2 * depth_); - if (!buffer_) throw std::bad_alloc(); size_type i = size_; switch (depth_) { + case 0: + depth_ = sizeof(uint8_t); + create(0); + return; #define BOOST_HISTOGRAM_NSTORE_GROW(T0, T1) \ case sizeof(T0): \ + depth_ = sizeof(T1); \ + buffer_ = std::realloc(buffer_, size_ * depth_); \ + if (!buffer_) throw std::bad_alloc(); \ while (i--) \ ((T1*)buffer_)[i] = ((T0*)buffer_)[i]; \ - depth_ = sizeof(T1); \ - break + return BOOST_HISTOGRAM_NSTORE_GROW(uint8_t, uint16_t); BOOST_HISTOGRAM_NSTORE_GROW(uint16_t, uint32_t); BOOST_HISTOGRAM_NSTORE_GROW(uint32_t, uint64_t);