1 /*
2 * Inkscape::Debug::SysVHeap - malloc() statistics via System V interface
3 *
4 * Authors:
5 * MenTaLguY <mental@rydia.net>
6 *
7 * Copyright (C) 2005 MenTaLguY
8 *
9 * Released under GNU GPL, read the file 'COPYING' for more information
10 */
12 #ifdef HAVE_CONFIG_H
13 # include "config.h"
14 #endif
16 #ifdef HAVE_MALLOC_H
17 # include <malloc.h>
18 #endif
20 #include "debug/sysv-heap.h"
22 namespace Inkscape {
23 namespace Debug {
25 int SysVHeap::features() const {
26 #ifdef HAVE_MALLINFO
27 return SIZE_AVAILABLE | USED_AVAILABLE;
28 #else
29 return 0;
30 #endif
31 }
33 Heap::Stats SysVHeap::stats() const {
34 Stats stats = { 0, 0 };
36 #ifdef HAVE_MALLINFO
37 struct mallinfo info=mallinfo();
39 #ifdef HAVE_STRUCT_MALLINFO_USMBLKS
40 stats.size += info.usmblks;
41 stats.bytes_used += info.usmblks;
42 #endif
44 #ifdef HAVE_STRUCT_MALLINFO_FSMBLKS
45 stats.size += info.fsmblks;
46 #endif
48 #ifdef HAVE_STRUCT_MALLINFO_UORDBLKS
49 stats.size += info.uordblks;
50 stats.bytes_used += info.uordblks;
51 #endif
53 #ifdef HAVE_STRUCT_MALLINFO_FORDBLKS
54 stats.size += info.fordblks;
55 #endif
57 #ifdef HAVE_STRUCT_MALLINFO_HBLKHD
58 stats.size += info.hblkhd;
59 stats.bytes_used += info.hblkhd;
60 #endif
62 #endif
64 return stats;
65 }
67 }
68 }
70 /*
71 Local Variables:
72 mode:c++
73 c-file-style:"stroustrup"
74 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
75 indent-tabs-mode:nil
76 fill-column:99
77 End:
78 */
79 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :