1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Inkscape::Debug::Heap - interface for gathering heap statistics 4 * 5 * Authors: 6 * MenTaLguY <mental@rydia.net> 7 * 8 * Copyright (C) 2005 MenTaLguY 9 * 10 * Released under GNU GPL v2+, read the file 'COPYING' for more information. 11 */ 12 13 #include "inkgc/gc-alloc.h" 14 #include "debug/gc-heap.h" 15 #include "debug/sysv-heap.h" 16 #include <vector> 17 18 namespace Inkscape { 19 namespace Debug { 20 21 namespace { 22 23 typedef std::vector<Heap *, GC::Alloc<Heap *, GC::MANUAL> > HeapCollection; 24 heaps()25HeapCollection &heaps() { 26 static bool is_initialized=false; 27 static HeapCollection heaps; 28 if (!is_initialized) { 29 heaps.push_back(new SysVHeap()); 30 heaps.push_back(new GCHeap()); 31 is_initialized = true; 32 } 33 return heaps; 34 } 35 36 } 37 heap_count()38unsigned heap_count() { 39 return heaps().size(); 40 } 41 get_heap(unsigned i)42Heap *get_heap(unsigned i) { 43 return heaps()[i]; 44 } 45 register_extra_heap(Heap & heap)46void register_extra_heap(Heap &heap) { 47 heaps().push_back(&heap); 48 } 49 50 } 51 } 52 53 /* 54 Local Variables: 55 mode:c++ 56 c-file-style:"stroustrup" 57 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) 58 indent-tabs-mode:nil 59 fill-column:99 60 End: 61 */ 62 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : 63