edbee - Qt Editor Library v0.11.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
debug_allocs.h
Go to the documentation of this file.
1// edbee - Copyright (c) 2012-2025 by Rick Blommers and contributors
2// SPDX-License-Identifier: MIT
3
7#pragma once
8
9#include "edbee/exports.h"
10
11
12
13#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
14 #define EdbeeRecursiveMutex QMutex
15#else
16 #define EdbeeRecursiveMutex QRecursiveMutex
17#endif
18
20
21
22//#if !defined(__APPLE__)
23//#include <malloc>
24//#endif
25#include <cstring> // for size_t
26#include <map>
27
28namespace edbee {
29
32{
33 void* pointer;
34 std::size_t size;
35 char* file;
36 int line;
37// MemoryLeakInfo() : p(0), size(0), file(0), line(0) {}
38// MemoryLeakInfo( void *p1, std::size_t size1, char *file1, int line1) : p(p1), size(size1), file(file1), line(line1) {}
39 void clear() { pointer=0; size=0; file=0; line=0; }
40};
41
44public:
45
47 virtual ~DebugAllocationList();
48
49 void clear();
50 size_t size() { return allocationList_.size(); }
51 inline bool isRunning() { return running_; }
52
53 void pause( bool val )
54 {
55 if( started_ ) {
56 running_ = !val;
57 }
58 }
59
60
61 EdbeeRecursiveMutex* mutex();
62
63public:
64 void start( bool checkDelete );
65 int stop();
66
67 DebugAllocation* find(void* p);
68 DebugAllocation* add (void* p, size_t size, char* file, int line);
69 bool del (void* p);
70
71 bool checkDelete();
72
73public:
74
75 static DebugAllocationList* instance();
76
77
78private:
79 std::map< void *, DebugAllocation*> allocationList_;
80 bool checkDelete_;
81 EdbeeRecursiveMutex* mutex_;
82 bool running_;
83 bool started_;
84
85
86 friend void* debug_malloc(size_t size, const char* file, const int line);
87 friend void debug_free (void* p, const char* file, const int line);
88
89
90};
91
92
93} // edbee
This class is used to remember all memory leakds.
Definition debug_allocs.h:43
DebugAllocationList()
cnostructs the allocation list
Definition debug_allocs.cpp:28
bool isRunning()
Definition debug_allocs.h:51
void pause(bool val)
Definition debug_allocs.h:53
size_t size()
Definition debug_allocs.h:50
friend void * debug_malloc(size_t size, const char *file, const int line)
void clear()
clears the debugging allocation list
Definition debug_allocs.cpp:55
friend void debug_free(void *p, const char *file, const int line)
#define EdbeeRecursiveMutex
Cross Platform Memory Leak Detection. Original source from: http://www.gilgil.net by Gilbert Lee....
Definition debug_allocs.h:16
#define EDBEE_EXPORT
Definition exports.h:15
#define add(key, value)
Definition factorykeymap.cpp:13
QT Acessibility has an issue with reporting blank lines between elements lines. defining 'WINDOWS_EMP...
Definition commentcommand.cpp:20
This structure is used to 'remember' what is allocated at which place.
Definition debug_allocs.h:32
std::size_t size
Definition debug_allocs.h:34
int line
Definition debug_allocs.h:36
char * file
Definition debug_allocs.h:35
void * pointer
Definition debug_allocs.h:33
void clear()
Definition debug_allocs.h:39