diff --git a/spot/priv/Makefile.am b/spot/priv/Makefile.am index 317292bd3..b2c75ab7d 100644 --- a/spot/priv/Makefile.am +++ b/spot/priv/Makefile.am @@ -1,5 +1,5 @@ ## -*- coding: utf-8 -*- -## Copyright (C) 2013-2019, 2021 Laboratoire de Recherche et +## Copyright (C) 2013-2019, 2021-2022 Laboratoire de Recherche et ## Développement de l'Epita (LRDE). ## ## This file is part of Spot, a model checking library. @@ -24,7 +24,6 @@ AM_CXXFLAGS = $(WARNING_CXXFLAGS) noinst_LTLIBRARIES = libpriv.la libpriv_la_SOURCES = \ accmap.hh \ - allocator.hh \ bddalloc.cc \ bddalloc.hh \ freelist.cc \ diff --git a/spot/priv/allocator.hh b/spot/priv/allocator.hh deleted file mode 100644 index 9c3d50268..000000000 --- a/spot/priv/allocator.hh +++ /dev/null @@ -1,104 +0,0 @@ -// -*- coding: utf-8 -*- -// Copyright (C) 2011, 2015-2018 Laboratoire de Recherche et -// Développement de l'Epita (LRDE) -// -// This file is part of Spot, a model checking library. -// -// Spot is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 3 of the License, or -// (at your option) any later version. -// -// Spot is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -// License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#pragma once - -#include - -namespace spot -{ - /// An allocator to be used with STL containers. - /// It uses a spot::fixed_size_pool to handle memory. - /// It is intended to improve performance and locality of node-based - /// containers (std::{unordered}{multi}{set,map}). - /// It is geared towards efficiently allocating memory for one object at a - /// time (the nodes of the node-based containers). Larger allocations are - /// served by calling the global memory allocation mechanism (::operator new). - /// Using it for contiguous containers (such as std::vector or std::deque) - /// will be less efficient than using the default std::allocator. - /// - /// Short reminder on STL concept of Allocator: - /// allocate() may throw - /// deallocate() must not throw - /// equality testing (i.e. == and !=) must not throw - /// copying allocator (constructor and assignment) must not throw - /// moving allocator (constructor and assignment) must not throw - /// - /// WARNING this class is NOT thread-safe: the allocator relies on a static - /// fixed_size_pool (which is not thread-safe either). - template - class pool_allocator - { - static - fixed_size_pool& - pool() - { - static fixed_size_pool p = - fixed_size_pool(sizeof(T)); - return p; - } - - public: - using value_type = T; - using pointer = value_type*; - using const_pointer = const value_type*; - using size_type = size_t; - - constexpr pool_allocator() noexcept - {} - template - constexpr pool_allocator(const pool_allocator&) noexcept - {} - - template - struct rebind - { - using other = pool_allocator; - }; - - pointer - allocate(size_type n) - { - if (SPOT_LIKELY(n == 1)) - return static_cast(pool().allocate()); - else - return static_cast(::operator new(n*sizeof(T))); - } - - void - deallocate(pointer ptr, size_type n) noexcept - { - if (SPOT_LIKELY(n == 1)) - pool().deallocate(static_cast(ptr)); - else - ::operator delete(ptr); - } - - bool - operator==(const pool_allocator&) const noexcept - { - return true; - } - bool - operator!=(const pool_allocator& o) const noexcept - { - return !(this->operator==(o)); - } - }; -} diff --git a/tests/core/mempool.cc b/tests/core/mempool.cc index 9d3610df7..1431a24b2 100644 --- a/tests/core/mempool.cc +++ b/tests/core/mempool.cc @@ -23,9 +23,6 @@ #include #include -#include - -#include namespace { @@ -157,32 +154,6 @@ int main() c->incr(); // no delete: valgrind should find a leak } - { - std::set, spot::pool_allocator> s; - s.insert(1); - s.insert(2); - s.insert(1); - s.erase(1); - s.insert(3); - s.insert(4); - - s.clear(); - - auto t = s; - t.insert(5); - t.insert(6); - - std::swap(s, t); - - s.erase(5); - s.erase(6); - - if (s != t) - return 1; - else - return 0; - } - return 0; }