d->begin = d->end = 0;
}
+void QListData::dispose(Data *d)
+{
+ Q_ASSERT(!d->ref.isShared());
+ free(d);
+}
+
// ensures that enough space is available to append n elements
void **QListData::append(int n)
{
Data *detach(int alloc);
Data *detach_grow(int *i, int n);
void realloc(int alloc);
+ inline void dispose() { dispose(d); }
+ static void dispose(Data *d);
static const Data shared_null;
Data *d;
void **erase(void **xi);
node_copy(reinterpret_cast<Node *>(p.begin()),
reinterpret_cast<Node *>(p.begin() + i), n);
} QT_CATCH(...) {
- free(d);
+ p.dispose();
d = x;
QT_RETHROW;
}
} QT_CATCH(...) {
node_destruct(reinterpret_cast<Node *>(p.begin()),
reinterpret_cast<Node *>(p.begin() + i));
- free(d);
+ p.dispose();
d = x;
QT_RETHROW;
}
QT_TRY {
node_copy(reinterpret_cast<Node *>(p.begin()), reinterpret_cast<Node *>(p.end()), n);
} QT_CATCH(...) {
- free(d);
+ p.dispose();
d = x;
QT_RETHROW;
}
struct Cleanup
{
Cleanup(QListData::Data *d) : d_(d) {}
- ~Cleanup() { if (d_) free(d_); }
+ ~Cleanup() { if (d_) QListData::dispose(d_); }
QListData::Data *d_;
} tryCatch(d);
{
node_destruct(reinterpret_cast<Node *>(data->array + data->begin),
reinterpret_cast<Node *>(data->array + data->end));
- free(data);
+ QListData::dispose(data);
}