// SPDX-License-Identifier: GPL-2.0-or-later /** @file * Inkscape::GC::Alloc - GC-aware STL allocator *//* * Authors: * see git history * MenTaLguY * * Copyright (C) 2018 Authors * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ #ifndef SEEN_INKSCAPE_GC_ALLOC_H #define SEEN_INKSCAPE_GC_ALLOC_H #include #include "inkgc/gc-core.h" namespace Inkscape { namespace GC { template class Alloc { public: typedef T value_type; typedef T *pointer; typedef std::size_t size_type; template struct rebind { typedef Alloc other; }; Alloc() = default; template Alloc(Alloc const &) {} pointer allocate(size_type count, void const * =nullptr) { return static_cast(::operator new(count * sizeof(T), SCANNED, collect)); } void deallocate(pointer p, size_type) { ::operator delete(p, GC); } }; // allocators with the same collection policy are interchangeable template bool operator==(Alloc const &, Alloc const &) { return collect1 == collect2; } template bool operator!=(Alloc const &, Alloc const &) { return collect1 != collect2; } } } #endif /* Local Variables: mode:c++ c-file-style:"stroustrup" c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :