Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qv4alloca_p.h
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
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
4
5
#
ifndef
QV4_ALLOCA_H
6
#
define
QV4_ALLOCA_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtCore
/
private
/
qglobal_p
.
h
>
20
21
#
include
<
stdlib
.
h
>
22
#
if
__has_include
(
<
alloca
.
h
>
)
23
#
include
<
alloca
.
h
>
24
#
endif
25
#
if
__has_include
(
<
malloc
.
h
>
)
26
#
include
<
malloc
.
h
>
27
#
endif
28
29
#
ifdef
Q_CC_MSVC
30
// This does not matter unless compiling in strict standard mode.
31
#
define
alloca
_alloca
32
#
endif
33
34
// Define Q_ALLOCA_VAR macro to be used instead of #ifdeffing
35
// the occurrences of alloca() in case it's not supported.
36
// * Q_ALLOCA_INIT belongs in the functions root scope and does RAII.
37
// * Q_ALLOCA_DECLARE declares the pointer and assigns it nullptr.
38
// * Q_ALLOCA_ASSIGN does the actual memory allocation.
39
#
define
Q_ALLOCA_VAR
(
type
,
name
,
size
)
40
Q_ALLOCA_DECLARE
(
type
,
name
)
;
41
Q_ALLOCA_ASSIGN
(
type
,
name
,
size
)
42
43
#
ifdef
alloca
44
45
#
define
Q_ALLOCA_INIT
(
)
46
#
define
Q_ALLOCA_DECLARE
(
type
,
name
)
type
*
name
=
nullptr
47
#
define
Q_ALLOCA_ASSIGN
(
type
,
name
,
size
)
name
=
static_cast
<
type
*
>
(
alloca
(
size
)
)
48
49
#
else
50
#
include
<
memory
>
51
#
include
<
qvarlengtharray
.
h
>
52
53
#
define
Q_ALLOCA_INIT
(
)
QVarLengthArray
<
std
::
unique_ptr
<
char
[
]
>
,
1
>
_qt_alloca
54
55
#
define
Q_ALLOCA_DECLARE
(
type
,
name
)
type
*
name
=
nullptr
56
57
#
define
Q_ALLOCA_ASSIGN
(
type
,
name
,
size
)
58
name
=
reinterpret_cast
<
type
*
>
(
_qt_alloca
.
emplace_back
(
new
char
[
size
]
)
.
get
(
)
)
59
60
#
endif
61
62
#
endif
__has_include
#define __has_include(x)
Definition
qcompilerdetection.h:459
Q_ALLOCA_ASSIGN
#define Q_ALLOCA_ASSIGN(type, name, size)
Definition
qv4alloca_p.h:57
Q_ALLOCA_DECLARE
#define Q_ALLOCA_DECLARE(type, name)
Definition
qv4alloca_p.h:55
qtdeclarative
src
qml
common
qv4alloca_p.h
Generated on
for Qt by
1.18.0