Skip to content

Commit

Permalink
Extract header qmalloc.h from qglobal.h
Browse files Browse the repository at this point in the history
Definitions of qMallocAligned()/qReallocAligned()/qFreeAligned() were
already in qmalloc.cpp, so add qmalloc.h for declarations.

Task-number: QTBUG-99313
Change-Id: I8028402a2c48dede855ad7de35d7b77e9911c761
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
Sona Kurazyan committed Aug 25, 2022
1 parent d954439 commit 48aa320
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/corelib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ qt_internal_add_module(Core
global/qhooks.cpp global/qhooks_p.h
global/qlibraryinfo.cpp global/qlibraryinfo.h global/qlibraryinfo_p.h
global/qlogging.cpp global/qlogging.h global/qlogging_p.h
global/qmalloc.cpp
global/qmalloc.cpp global/qmalloc.h
global/qminmax.h
global/qnamespace.h # this header is specified on purpose so AUTOMOC processes it
global/qnativeinterface.h global/qnativeinterface_p.h
Expand Down
5 changes: 1 addition & 4 deletions src/corelib/global/qglobal.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@ typedef void (*QFunctionPointer)();
# define Q_UNIMPLEMENTED() qWarning("Unimplemented code.")
#endif

Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment) Q_ALLOC_SIZE(1);
Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment) Q_ALLOC_SIZE(2);
Q_CORE_EXPORT void qFreeAligned(void *ptr);


// this adds const to non-const objects (like std::as_const)
template <typename T>
Expand Down Expand Up @@ -174,6 +170,7 @@ QT_END_NAMESPACE
#include <QtCore/qexceptionhandling.h>
#include <QtCore/qforeach.h>
#include <QtCore/qglobalstatic.h>
#include <QtCore/qmalloc.h>
#include <QtCore/qminmax.h>
#include <QtCore/qnumeric.h>
#include <QtCore/qoverload.h>
Expand Down
1 change: 1 addition & 0 deletions src/corelib/global/qmalloc.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "qmalloc.h"
#include "qplatformdefs.h"

#include <stdlib.h>
Expand Down
22 changes: 22 additions & 0 deletions src/corelib/global/qmalloc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QMALLOC_H
#define QMALLOC_H

#include <QtCore/qglobal.h>

#if 0
#pragma qt_class(QtMalloc)
#pragma qt_sync_stop_processing
#endif

QT_BEGIN_NAMESPACE

Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment) Q_ALLOC_SIZE(1);
Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment) Q_ALLOC_SIZE(2);
Q_CORE_EXPORT void qFreeAligned(void *ptr);

QT_END_NAMESPACE

#endif // QMALLOC_H

0 comments on commit 48aa320

Please sign in to comment.