Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4
#ifndef QV4_ALLOCA_H
5
#define QV4_ALLOCA_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#include <QtCore/private/qglobal_p.h>
19
20
#if QT_CONFIG(alloca_h)
21
# include <alloca.h>
22
#elif QT_CONFIG(alloca_malloc_h)
23
# include <malloc.h>
24
// This does not matter unless compiling in strict standard mode.
25
# ifdef Q_CC_MSVC
26
# define alloca _alloca
27
# endif
28
#else
29
# include <stdlib.h>
30
#endif
31
32
// Define Q_ALLOCA_VAR macro to be used instead of #ifdeffing
33
// the occurrences of alloca() in case it's not supported.
34
// Q_ALLOCA_DECLARE and Q_ALLOCA_ASSIGN macros separate
35
// memory allocation from the declaration and RAII.
36
#define Q_ALLOCA_VAR(type, name, size) \
37
Q_ALLOCA_DECLARE(type, name); \
38
Q_ALLOCA_ASSIGN(type, name, size)
39
40
#if QT_CONFIG(alloca)
41
42
#define Q_ALLOCA_DECLARE(type, name) \
43
type *name = 0
44
45
#define Q_ALLOCA_ASSIGN(type, name, size) \
46
name = static_cast<type*>(alloca(size))
47
48
#else
49
QT_BEGIN_NAMESPACE
50
class
Qt_AllocaWrapper
51
{
52
public
:
53
Qt_AllocaWrapper
() { m_data = 0; }
54
~Qt_AllocaWrapper
() { free(m_data); }
55
void
*
data
() {
return
m_data; }
56
void
allocate
(
int
size
) { m_data = malloc(
size
); memset(m_data, 0,
size
); }
57
private
:
58
void
*m_data;
59
};
60
QT_END_NAMESPACE
61
62
#define Q_ALLOCA_DECLARE(type, name) \
63
Qt_AllocaWrapper _qt_alloca_##name; \
64
type *name = nullptr
65
66
#define Q_ALLOCA_ASSIGN(type, name, size) \
67
do { \
68
_qt_alloca_##name.allocate(size); \
69
name = static_cast<type*>(_qt_alloca_##name.data()); \
70
} while (false)
71
72
#endif
73
74
#endif
Qt_AllocaWrapper
Definition
qv4alloca_p.h:51
Qt_AllocaWrapper::data
void * data()
Definition
qv4alloca_p.h:55
Qt_AllocaWrapper::~Qt_AllocaWrapper
~Qt_AllocaWrapper()
Definition
qv4alloca_p.h:54
Qt_AllocaWrapper::allocate
void allocate(int size)
Definition
qv4alloca_p.h:56
Qt_AllocaWrapper::Qt_AllocaWrapper
Qt_AllocaWrapper()
Definition
qv4alloca_p.h:53
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qstandardpaths_haiku.cpp:21
QT_END_NAMESPACE
Definition
qsharedpointer.cpp:1590
size
GLenum GLuint GLintptr GLsizeiptr size
[1]
Definition
qopengles2ext.h:660
qtdeclarative
src
qml
common
qv4alloca_p.h
Generated by
1.10.0