aboutsummaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/code/doc_src_debug.cpp
blob: 291d25450c694cf248f91352610d7e22e855c3b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

//! [0]
qDebug() << "Widget" << widget << "at position" << widget->pos();
//! [0]


//! [1]
char *alloc(int size)
{
    Q_ASSERT(size > 0);
    char *ptr = new char[size];
    Q_CHECK_PTR(ptr);
    return ptr;
}
//! [1]


//! [2]
char *alloc(int size)
{
    char *ptr;
    Q_CHECK_PTR(ptr = new char[size]);  // WRONG
    return ptr;
}
//! [2]