Skip to content

Commit

Permalink
fix #42: Using delete operator for the memory allocated with placemen…
Browse files Browse the repository at this point in the history
…t new

Also bump version to 1.0.1 for that fix
  • Loading branch information
martinus committed Jul 19, 2022
1 parent 968d215 commit 143ea3b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.12)
project("svector"
VERSION 1.0.0
VERSION 1.0.1
DESCRIPTION " Compact SVO optimized vector for C++17 or higher"
HOMEPAGE_URL "https://github.com/martinus/svector")

Expand Down
15 changes: 10 additions & 5 deletions include/ankerl/svector.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ┌─┐┬ ┬┌─┐┌─┐┌┬┐┌─┐┬─┐ Compact SVO optimized vector C++17 or higher
// └─┐└┐┌┘├┤ │ │ │ │├┬┘ Version 1.0.0
// └─┐└┐┌┘├┤ │ │ │ │├┬┘ Version 1.0.1
// └─┘ └┘ └─┘└─┘ ┴ └─┘┴└─ https://github.com/martinus/svector
//
// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
Expand Down Expand Up @@ -30,7 +30,7 @@
// see https://semver.org/spec/v2.0.0.html
#define ANKERL_SVECTOR_VERSION_MAJOR 1 // incompatible API changes
#define ANKERL_SVECTOR_VERSION_MINOR 0 // add functionality in a backwards compatible manner
#define ANKERL_SVECTOR_VERSION_PATCH 0 // backwards compatible bug fixes
#define ANKERL_SVECTOR_VERSION_PATCH 1 // backwards compatible bug fixes

// API versioning with inline namespace, see https://www.foonathan.net/2018/11/inline-namespaces/
#define ANKERL_SVECTOR_VERSION_CONCAT1(major, minor, patch) v##major##_##minor##_##patch
Expand Down Expand Up @@ -272,7 +272,8 @@ class svector {
auto* storage = indirect();
uninitialized_move_and_destroy(storage->data(), direct_data(), storage->size());
set_direct_and_size(storage->size());
delete storage;
std::destroy_at(storage);
::operator delete(storage);
} else {
// put everything into indirect storage
auto* storage = detail::storage<T>::alloc(new_capacity);
Expand All @@ -284,7 +285,9 @@ class svector {
// indirect -> indirect
uninitialized_move_and_destroy(data<direction::indirect>(), storage->data(), size<direction::indirect>());
storage->size(size<direction::indirect>());
delete indirect();
auto* storage = indirect();
std::destroy_at(storage);
::operator delete(storage);
}
set_indirect(storage);
}
Expand Down Expand Up @@ -522,7 +525,9 @@ class svector {
std::destroy_n(ptr, s);
}
if (!is_dir) {
delete indirect();
auto* storage = indirect();
std::destroy_at(storage);
::operator delete(storage);
}
}

Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#

project('svector', 'cpp',
version: '1.0.0',
version: '1.0.1',
license: 'MIT',
default_options : ['cpp_std=c++17', 'warning_level=3', 'werror=true'])

Expand Down
4 changes: 2 additions & 2 deletions scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
['env', 'CXX=ccache g++', 'meson', 'setup', '-Db_sanitize=thread', 'builddir/gcc_sanitize_thread'],
['env', 'CXX=ccache clang++', 'meson', 'setup', '-Db_sanitize=thread', 'builddir/clang_sanitize_thread'],

['env', 'CXX=ccache g++', 'meson', 'setup', '-Db_sanitize=memory', 'builddir/gcc_sanitize_memory'], # doesn't work due to STL, and ignore doesn't work either :-(
#['env', 'CXX=ccache clang++', 'meson', 'setup', '-Db_sanitize=memory', 'builddir/clang_sanitize_memory'], # doesn't work due to STL, and ignore doesn't work either :-(
# ['env', 'CXX=ccache g++', 'meson', 'setup', '-Db_sanitize=memory', 'builddir/gcc_sanitize_memory'], # doesn't work due to STL, and ignore doesn't work either :-(
# ['env', 'CXX=ccache clang++', 'meson', 'setup', '-Db_sanitize=memory', 'builddir/clang_sanitize_memory'], # doesn't work due to STL, and ignore doesn't work either :-(

['env', 'CXX=ccache g++', 'meson', 'setup', '-Db_sanitize=undefined', 'builddir/gcc_sanitize_undefined'],
['env', 'CXX=ccache clang++', 'meson', 'setup', '-Db_sanitize=undefined', 'builddir/clang_sanitize_undefined'],
Expand Down

0 comments on commit 143ea3b

Please sign in to comment.