mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 19:02:59 +00:00
get rid of q_check_ptr()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
3a7005f518
commit
07675ce888
12 changed files with 37 additions and 32 deletions
|
@ -1125,15 +1125,6 @@ bool qSharedBuild()
|
|||
\sa qWarning(), {Debugging Techniques}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn T *q_check_ptr(T *pointer)
|
||||
\relates <QtGlobal>
|
||||
|
||||
Users Q_CHECK_PTR on \a pointer, then returns \a pointer.
|
||||
|
||||
This can be used as an inline version of Q_CHECK_PTR.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\macro const char* Q_FUNC_INFO()
|
||||
\relates <QtGlobal>
|
||||
|
|
|
@ -554,9 +554,6 @@ Q_CORE_EXPORT void qBadAlloc();
|
|||
# define Q_CHECK_PTR(p) do { if (!(p)) qBadAlloc(); } while (0)
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; }
|
||||
|
||||
enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg };
|
||||
|
||||
Q_CORE_EXPORT void qt_message_output(QtMsgType, const char *buf);
|
||||
|
|
|
@ -1366,7 +1366,8 @@ void QRegExpMatchState::prepareForMatch(QRegExpEngine *eng)
|
|||
#endif
|
||||
int numCaptures = eng->captureCount();
|
||||
int newCapturedSize = 2 + 2 * numCaptures;
|
||||
bigArray = q_check_ptr((int *)realloc(bigArray, ((3 + 4 * ncap) * ns + 4 * ncap + newSlideTabSize + newCapturedSize)*sizeof(int)));
|
||||
bigArray = (int *)::realloc(bigArray, ((3 + 4 * ncap) * ns + 4 * ncap + newSlideTabSize + newCapturedSize)*sizeof(int));
|
||||
Q_CHECK_PTR(bigArray);
|
||||
|
||||
// set all internal variables only _after_ bigArray is realloc'ed
|
||||
// to prevent a broken regexp in oom case
|
||||
|
|
|
@ -1134,8 +1134,8 @@ void QDeclarativeData::setBindingBit(QObject *obj, int bit)
|
|||
int arraySize = (props + 31) / 32;
|
||||
int oldArraySize = bindingBitsSize / 32;
|
||||
|
||||
bindingBits = (quint32 *)q_check_ptr(realloc(bindingBits,
|
||||
arraySize * sizeof(quint32)));
|
||||
bindingBits = (quint32 *)::realloc(bindingBits, arraySize * sizeof(quint32));
|
||||
Q_CHECK_PTR(bindingBits);
|
||||
|
||||
memset(bindingBits + oldArraySize,
|
||||
0x00,
|
||||
|
|
|
@ -81,7 +81,8 @@ public:
|
|||
void insert(int idx, const T &v) {
|
||||
if (m_count == m_capacity) {
|
||||
m_capacity += Increment;
|
||||
m_data = (T *)q_check_ptr(realloc(m_data, m_capacity * sizeof(T)));
|
||||
m_data = (T *)::realloc(m_data, m_capacity * sizeof(T));
|
||||
Q_CHECK_PTR(m_data);
|
||||
}
|
||||
int moveCount = m_count - idx;
|
||||
if (moveCount)
|
||||
|
@ -93,7 +94,8 @@ public:
|
|||
void reserve(int count) {
|
||||
if (count >= m_capacity) {
|
||||
m_capacity = (count + (Increment-1)) & (0xFFFFFFFF - Increment + 1);
|
||||
m_data = (T *)q_check_ptr(realloc(m_data, m_capacity * sizeof(T)));
|
||||
m_data = (T *)::realloc(m_data, m_capacity * sizeof(T));
|
||||
Q_CHECK_PTR(m_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -182,7 +182,8 @@ void QDesktopWidgetPrivate::init()
|
|||
|
||||
if (screens) {
|
||||
// leaks QWidget* pointers on purpose, can't delete them as pointer escapes
|
||||
screens = q_check_ptr((QWidget**) realloc(screens, j * sizeof(QWidget*)));
|
||||
screens = (QWidget**)::realloc(screens, j * sizeof(QWidget*));
|
||||
Q_CHECK_PTR(screens);
|
||||
if (j > screenCount)
|
||||
memset(&screens[screenCount], 0, (j-screenCount) * sizeof(QWidget*));
|
||||
}
|
||||
|
|
|
@ -2908,7 +2908,8 @@ void QClipData::initialize()
|
|||
{ // resize
|
||||
const int maxSpans = (ymax - ymin) * numRects;
|
||||
if (maxSpans > allocated) {
|
||||
m_spans = q_check_ptr((QSpan *)realloc(m_spans, maxSpans * sizeof(QSpan)));
|
||||
m_spans = (QSpan *)::realloc(m_spans, maxSpans * sizeof(QSpan));
|
||||
Q_CHECK_PTR(m_spans);
|
||||
allocated = maxSpans;
|
||||
}
|
||||
}
|
||||
|
@ -3244,7 +3245,8 @@ static void qt_span_clip(int count, const QSpan *spans, void *userData)
|
|||
&newspans, newClip->allocated - newClip->count);
|
||||
newClip->count = newspans - newClip->m_spans;
|
||||
if (spans < end) {
|
||||
newClip->m_spans = q_check_ptr((QSpan *)realloc(newClip->m_spans, newClip->allocated*2*sizeof(QSpan)));
|
||||
newClip->m_spans = (QSpan *)::realloc(newClip->m_spans, newClip->allocated*2*sizeof(QSpan));
|
||||
Q_CHECK_PTR(newClip->m_spans);
|
||||
newClip->allocated *= 2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -212,7 +212,8 @@ void QXRenderTessellator::addTrap(const Trapezoid &trap)
|
|||
{
|
||||
if (size == allocated) {
|
||||
allocated = qMax(2*allocated, 64);
|
||||
traps = q_check_ptr((XTrapezoid *)realloc(traps, allocated * sizeof(XTrapezoid)));
|
||||
traps = (XTrapezoid *)::realloc(traps, allocated * sizeof(XTrapezoid));
|
||||
Q_CHECK_PTR(traps);
|
||||
}
|
||||
traps[size].top = Q27Dot5ToXFixed(trap.top);
|
||||
traps[size].bottom = Q27Dot5ToXFixed(trap.bottom);
|
||||
|
|
|
@ -184,13 +184,14 @@ bool QPainterPrivate::attachPainterPrivate(QPainter *q, QPaintDevice *pdev)
|
|||
// redirections within the same paintEvent(), which should be enough
|
||||
// in 99% of all cases). E.g: A renders B which renders C which renders D.
|
||||
sp->d_ptr->d_ptrs_size = 4;
|
||||
sp->d_ptr->d_ptrs = (QPainterPrivate **)malloc(4 * sizeof(QPainterPrivate *));
|
||||
sp->d_ptr->d_ptrs = (QPainterPrivate **)::malloc(4 * sizeof(QPainterPrivate *));
|
||||
Q_CHECK_PTR(sp->d_ptr->d_ptrs);
|
||||
} else if (sp->d_ptr->refcount - 1 == sp->d_ptr->d_ptrs_size) {
|
||||
// However, to support corner cases we grow the array dynamically if needed.
|
||||
sp->d_ptr->d_ptrs_size <<= 1;
|
||||
const int newSize = sp->d_ptr->d_ptrs_size * sizeof(QPainterPrivate *);
|
||||
sp->d_ptr->d_ptrs = q_check_ptr((QPainterPrivate **)realloc(sp->d_ptr->d_ptrs, newSize));
|
||||
sp->d_ptr->d_ptrs = (QPainterPrivate **)::realloc(sp->d_ptr->d_ptrs, newSize);
|
||||
Q_CHECK_PTR(sp->d_ptr->d_ptrs);
|
||||
}
|
||||
sp->d_ptr->d_ptrs[++sp->d_ptr->refcount - 2] = q->d_ptr.data();
|
||||
q->d_ptr.take();
|
||||
|
|
|
@ -426,7 +426,8 @@ inline void QScanConverter::allocate(int size)
|
|||
{
|
||||
if (m_alloc < size) {
|
||||
int newAlloc = qMax(size, 2 * m_alloc);
|
||||
m_intersections = q_check_ptr((Intersection *)realloc(m_intersections, newAlloc * sizeof(Intersection)));
|
||||
m_intersections = (Intersection *)::realloc(m_intersections, newAlloc * sizeof(Intersection));
|
||||
Q_CHECK_PTR(m_intersections);
|
||||
m_alloc = newAlloc;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -394,9 +394,12 @@ void QTessellatorPrivate::Scanline::init(int maxActiveEdges)
|
|||
if (!edges || maxActiveEdges > default_alloc) {
|
||||
max_edges = maxActiveEdges;
|
||||
int s = qMax(maxActiveEdges + 1, default_alloc + 1);
|
||||
edges = q_check_ptr((Edge **)realloc(edges, s*sizeof(Edge *)));
|
||||
edge_table = q_check_ptr((Edge *)realloc(edge_table, s*sizeof(Edge)));
|
||||
old = q_check_ptr((Edge **)realloc(old, s*sizeof(Edge *)));
|
||||
edges = (Edge **)::realloc(edges, s*sizeof(Edge *));
|
||||
Q_CHECK_PTR(edges);
|
||||
edge_table = (Edge *)::realloc(edge_table, s*sizeof(Edge));
|
||||
Q_CHECK_PTR(edge_table);
|
||||
old = (Edge **)::realloc(old, s*sizeof(Edge *));
|
||||
Q_CHECK_PTR(old);
|
||||
}
|
||||
size = 0;
|
||||
old_size = 0;
|
||||
|
@ -554,8 +557,10 @@ void QTessellatorPrivate::Vertices::init(int maxVertices)
|
|||
{
|
||||
if (!storage || maxVertices > allocated) {
|
||||
int size = qMax((int)default_alloc, maxVertices);
|
||||
storage = q_check_ptr((Vertex *)realloc(storage, size*sizeof(Vertex)));
|
||||
sorted = q_check_ptr((Vertex **)realloc(sorted, size*sizeof(Vertex *)));
|
||||
storage = (Vertex *)::realloc(storage, size*sizeof(Vertex));
|
||||
Q_CHECK_PTR(storage);
|
||||
sorted = (Vertex **)::realloc(sorted, size*sizeof(Vertex *));
|
||||
Q_CHECK_PTR(sorted);
|
||||
allocated = maxVertices;
|
||||
}
|
||||
}
|
||||
|
@ -727,7 +732,8 @@ void QTessellatorPrivate::cancelCoincidingEdges()
|
|||
|
||||
if (testListSize > tlSize - 2) {
|
||||
tlSize = qMax(tlSize*2, 16);
|
||||
tl = q_check_ptr((QCoincidingEdge *)realloc(tl, tlSize*sizeof(QCoincidingEdge)));
|
||||
tl = (QCoincidingEdge *)::realloc(tl, tlSize*sizeof(QCoincidingEdge));
|
||||
Q_CHECK_PTR(tl);
|
||||
}
|
||||
if (n->flags & (LineBeforeStarts|LineBeforeHorizontal)) {
|
||||
tl[testListSize].start = n;
|
||||
|
|
|
@ -437,7 +437,8 @@ void QTextTablePrivate::update() const
|
|||
nRows = (cells.size() + nCols-1)/nCols;
|
||||
// qDebug(">>>> QTextTablePrivate::update, nRows=%d, nCols=%d", nRows, nCols);
|
||||
|
||||
grid = q_check_ptr((int *)realloc(grid, nRows*nCols*sizeof(int)));
|
||||
grid = (int *)::realloc(grid, nRows*nCols*sizeof(int));
|
||||
Q_CHECK_PTR(grid);
|
||||
memset(grid, 0, nRows*nCols*sizeof(int));
|
||||
|
||||
QTextDocumentPrivate *p = pieceTable;
|
||||
|
@ -461,7 +462,8 @@ void QTextTablePrivate::update() const
|
|||
cellIndices[i] = cell;
|
||||
|
||||
if (r + rowspan > nRows) {
|
||||
grid = q_check_ptr((int *)realloc(grid, sizeof(int)*(r + rowspan)*nCols));
|
||||
grid = (int *)::realloc(grid, sizeof(int)*(r + rowspan)*nCols);
|
||||
Q_CHECK_PTR(grid);
|
||||
memset(grid + (nRows*nCols), 0, sizeof(int)*(r+rowspan-nRows)*nCols);
|
||||
nRows = r + rowspan;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue