-
Task
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
6.5.1
-
None
To report leaks, Microsoft uses defines to change memory allocation routines to a debug variant.
https://learn.microsoft.com/en-us/cpp/c-runtime-library/crtdbg-map-alloc?view=msvc-170
The define is _CRTDBG_MAP_ALLOC
There is a conflict in the qhash.h file. It uses 'free' as a function name.
#ifdef _CRTDBG_MAP_ALLOC #define calloc(c, s) _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__) #define _expand(p, s) _expand_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__) #define free(p) _free_dbg(p, _NORMAL_BLOCK)
template <typename T>
struct MultiNodeChain
{
T value;
MultiNodeChain *next = nullptr;
~MultiNodeChain()
{
}
qsizetype free() noexcept(std::is_nothrow_destructible_v<T>)
{
qsizetype nEntries = 0;
MultiNodeChain *e = this;
while (e) {
MultiNodeChain *n = e->next;
++nEntries;
delete e;
e = n;
}
return nEntries;
}
I could undefine it to include the file, but that can miss memory functions and create false reports.
#ifdef _CRTDBG_MAP_ALLOC #undef _CRTDBG_MAP_ALLOC #include <QHash> #define _CRTDBG_MAP_ALLOC #endif
It would help if the free function was renamed.
- duplicates
-
QTBUG-86395 Avoid use names malloc, realloc and free in API so MSVC's _CRTDBG_MAP_MALLOC is possible
-
- Closed
-