Skip to content

Commit 143ea3b

Browse files
committed
fix #42: Using delete operator for the memory allocated with placement new
Also bump version to 1.0.1 for that fix
1 parent 968d215 commit 143ea3b

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.12)
22
project("svector"
3-
VERSION 1.0.0
3+
VERSION 1.0.1
44
DESCRIPTION " Compact SVO optimized vector for C++17 or higher"
55
HOMEPAGE_URL "https://github.com/martinus/svector")
66

include/ankerl/svector.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ┌─┐┬ ┬┌─┐┌─┐┌┬┐┌─┐┬─┐ Compact SVO optimized vector C++17 or higher
2-
// └─┐└┐┌┘├┤ │ │ │ │├┬┘ Version 1.0.0
2+
// └─┐└┐┌┘├┤ │ │ │ │├┬┘ Version 1.0.1
33
// └─┘ └┘ └─┘└─┘ ┴ └─┘┴└─ https://github.com/martinus/svector
44
//
55
// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
@@ -30,7 +30,7 @@
3030
// see https://semver.org/spec/v2.0.0.html
3131
#define ANKERL_SVECTOR_VERSION_MAJOR 1 // incompatible API changes
3232
#define ANKERL_SVECTOR_VERSION_MINOR 0 // add functionality in a backwards compatible manner
33-
#define ANKERL_SVECTOR_VERSION_PATCH 0 // backwards compatible bug fixes
33+
#define ANKERL_SVECTOR_VERSION_PATCH 1 // backwards compatible bug fixes
3434

3535
// API versioning with inline namespace, see https://www.foonathan.net/2018/11/inline-namespaces/
3636
#define ANKERL_SVECTOR_VERSION_CONCAT1(major, minor, patch) v##major##_##minor##_##patch
@@ -272,7 +272,8 @@ class svector {
272272
auto* storage = indirect();
273273
uninitialized_move_and_destroy(storage->data(), direct_data(), storage->size());
274274
set_direct_and_size(storage->size());
275-
delete storage;
275+
std::destroy_at(storage);
276+
::operator delete(storage);
276277
} else {
277278
// put everything into indirect storage
278279
auto* storage = detail::storage<T>::alloc(new_capacity);
@@ -284,7 +285,9 @@ class svector {
284285
// indirect -> indirect
285286
uninitialized_move_and_destroy(data<direction::indirect>(), storage->data(), size<direction::indirect>());
286287
storage->size(size<direction::indirect>());
287-
delete indirect();
288+
auto* storage = indirect();
289+
std::destroy_at(storage);
290+
::operator delete(storage);
288291
}
289292
set_indirect(storage);
290293
}
@@ -522,7 +525,9 @@ class svector {
522525
std::destroy_n(ptr, s);
523526
}
524527
if (!is_dir) {
525-
delete indirect();
528+
auto* storage = indirect();
529+
std::destroy_at(storage);
530+
::operator delete(storage);
526531
}
527532
}
528533

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919

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

scripts/build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
['env', 'CXX=ccache g++', 'meson', 'setup', '-Db_sanitize=thread', 'builddir/gcc_sanitize_thread'],
3636
['env', 'CXX=ccache clang++', 'meson', 'setup', '-Db_sanitize=thread', 'builddir/clang_sanitize_thread'],
3737

38-
['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 :-(
39-
#['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 :-(
38+
# ['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 :-(
39+
# ['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 :-(
4040

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

0 commit comments

Comments
 (0)