Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qalloc.cpp
Go to the documentation of this file.
1
// Copyright (C) 2025 Aurélien Brooke <aurelien@bahiasoft.fr>
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
"qalloc.h"
6
7
#
include
<
QtCore
/
qalgorithms
.
h
>
8
#
include
<
QtCore
/
qtpreprocessorsupport
.
h
>
9
10
#
include
<
cstdlib
>
11
12
#
if
QT_CONFIG
(
jemalloc
)
13
#
include
<
jemalloc
/
jemalloc
.
h
>
14
#
endif
15
16
QT_BEGIN_NAMESPACE
17
18
size_t QtPrivate::expectedAllocSize(size_t allocSize, size_t alignment)
noexcept
19
{
20
Q_ASSERT(qPopulationCount(alignment) == 1);
21
#
if
QT_CONFIG
(
jemalloc
)
22
return
::nallocx(allocSize, MALLOCX_ALIGN(alignment));
23
#
endif
24
Q_UNUSED(allocSize);
25
Q_UNUSED(alignment);
26
return
0;
27
}
28
29
void
QtPrivate
::
sizedFree
(
void
*ptr, size_t allocSize)
noexcept
30
{
31
#
if
QT_CONFIG
(
jemalloc
)
32
// jemalloc is okay with free(nullptr), as required by the standard,
33
// but will asssert (in debug) or invoke UB (in release) on sdallocx(nullptr, ...),
34
// so don't allow Qt to do that.
35
if
(Q_LIKELY(ptr)) {
36
::sdallocx(ptr, allocSize, 0);
37
return
;
38
}
39
#
endif
40
Q_UNUSED(allocSize);
41
::free(ptr);
42
}
43
44
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
QtPrivate
Definition
qalloc.h:29
QtPrivate::sizedFree
Q_CORE_EXPORT void sizedFree(void *ptr, size_t allocSize) noexcept
Definition
qalloc.cpp:29
qtbase
src
corelib
global
qalloc.cpp
Generated on
for Qt by
1.16.1