Remove out-of-line uses of qMalloc/qFree/qRealloc.
authorRobin Burchell <robin.burchell@collabora.com>
Fri, 6 Jan 2012 18:20:55 +0000 (19:20 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 12 Jan 2012 15:21:35 +0000 (16:21 +0100)
Per http://codereview.qt-project.org/#change,11562, we are trying to remove these
in favour of direct allocation, or (in the case of inline code) specialised
out-of-line wrappers.

Change-Id: I113609c4f97dc5c8020a72cbd398572cdb5b7505
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
src/declarative/qml/parser/qdeclarativejs.g
src/declarative/qml/parser/qdeclarativejsparser.cpp
src/declarative/qml/qdeclarativeboundsignal.cpp
src/declarative/qml/qdeclarativeopenmetaobject.cpp
src/declarative/qml/qdeclarativepropertycache.cpp
src/qtquick1/util/qdeclarativeopenmetaobject.cpp
src/quick/items/qquickvisualadaptormodel.cpp
src/quick/items/qquickvisualdatamodel.cpp
src/quick/scenegraph/coreapi/qsggeometry.cpp
src/quick/scenegraph/qsgpathsimplifier.cpp

index f7f92a5..9ed2e86 100644 (file)
@@ -398,10 +398,10 @@ void Parser::reallocateStack()
     else
         stack_size <<= 1;
 
-    sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value)));
-    state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
-    location_stack = reinterpret_cast<AST::SourceLocation*> (qRealloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
-    string_stack = reinterpret_cast<QStringRef*> (qRealloc(string_stack, stack_size * sizeof(QStringRef)));
+    sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
+    state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
+    location_stack = reinterpret_cast<AST::SourceLocation*> (realloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
+    string_stack = reinterpret_cast<QStringRef*> (realloc(string_stack, stack_size * sizeof(QStringRef)));
 }
 
 Parser::Parser(Engine *engine):
@@ -421,10 +421,10 @@ Parser::Parser(Engine *engine):
 Parser::~Parser()
 {
     if (stack_size) {
-        qFree(sym_stack);
-        qFree(state_stack);
-        qFree(location_stack);
-        qFree(string_stack);
+        free(sym_stack);
+        free(state_stack);
+        free(location_stack);
+        free(string_stack);
     }
 }
 
index 29ef64b..1639900 100644 (file)
@@ -70,10 +70,10 @@ void Parser::reallocateStack()
     else
         stack_size <<= 1;
 
-    sym_stack = reinterpret_cast<Value*> (qRealloc(sym_stack, stack_size * sizeof(Value)));
-    state_stack = reinterpret_cast<int*> (qRealloc(state_stack, stack_size * sizeof(int)));
-    location_stack = reinterpret_cast<AST::SourceLocation*> (qRealloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
-    string_stack = reinterpret_cast<QStringRef*> (qRealloc(string_stack, stack_size * sizeof(QStringRef)));
+    sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
+    state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
+    location_stack = reinterpret_cast<AST::SourceLocation*> (realloc(location_stack, stack_size * sizeof(AST::SourceLocation)));
+    string_stack = reinterpret_cast<QStringRef*> (realloc(string_stack, stack_size * sizeof(QStringRef)));
 }
 
 Parser::Parser(Engine *engine):
@@ -93,10 +93,10 @@ Parser::Parser(Engine *engine):
 Parser::~Parser()
 {
     if (stack_size) {
-        qFree(sym_stack);
-        qFree(state_stack);
-        qFree(location_stack);
-        qFree(string_stack);
+        free(sym_stack);
+        free(state_stack);
+        free(location_stack);
+        free(string_stack);
     }
 }
 
index c7a8749..51691ca 100644 (file)
@@ -266,7 +266,7 @@ QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters(const QMeta
 QDeclarativeBoundSignalParameters::~QDeclarativeBoundSignalParameters()
 {
     delete [] types;
-    qFree(myMetaObject);
+    free(myMetaObject);
 }
 
 void QDeclarativeBoundSignalParameters::setValues(void **v)
index ad3013b..6dbd254 100644 (file)
@@ -75,7 +75,7 @@ QDeclarativeOpenMetaObjectType::QDeclarativeOpenMetaObjectType(const QMetaObject
 QDeclarativeOpenMetaObjectType::~QDeclarativeOpenMetaObjectType()
 {
     if (d->mem)
-        qFree(d->mem);
+        free(d->mem);
     if (d->cache)
         d->cache->release();
     delete d;
@@ -102,7 +102,7 @@ int QDeclarativeOpenMetaObjectType::createProperty(const QByteArray &name)
     d->mob.addSignal("__" + QByteArray::number(id) + "()");
     QMetaPropertyBuilder build = d->mob.addProperty(name, "QVariant", id);
     propertyCreated(id, build);
-    qFree(d->mem);
+    free(d->mem);
     d->mem = d->mob.toMetaObject();
     d->names.insert(name, id);
     QSet<QDeclarativeOpenMetaObject*>::iterator it = d->referers.begin();
index 55096ea..c3f197d 100644 (file)
@@ -254,7 +254,7 @@ QDeclarativePropertyCache::~QDeclarativePropertyCache()
     QDeclarativePropertyCacheMethodArguments *args = argumentsCache;
     while (args) {
         QDeclarativePropertyCacheMethodArguments *next = args->next;
-        qFree(args);
+        free(args);
         args = next;
     }
 
@@ -725,7 +725,7 @@ int *QDeclarativePropertyCache::methodParameterTypes(QObject *object, int index,
         QMetaMethod m = metaObject->method(index);
         QList<QByteArray> argTypeNames = m.parameterTypes();
 
-        A *args = static_cast<A *>(qMalloc(sizeof(A) + (argTypeNames.count() + 1) * sizeof(int)));
+        A *args = static_cast<A *>(malloc(sizeof(A) + (argTypeNames.count() + 1) * sizeof(int)));
         args->arguments[0] = argTypeNames.count();
 
         for (int ii = 0; ii < argTypeNames.count(); ++ii) {
@@ -734,7 +734,7 @@ int *QDeclarativePropertyCache::methodParameterTypes(QObject *object, int index,
                 type = EnumType(object->metaObject(), argTypeNames.at(ii));
             if (type == QVariant::Invalid) {
                 if (unknownTypeError) *unknownTypeError = argTypeNames.at(ii);
-                qFree(args);
+                free(args);
                 return 0;
             }
             args->arguments[ii + 1] = type;
index 8d1ab46..39583cf 100644 (file)
@@ -77,7 +77,7 @@ QDeclarative1OpenMetaObjectType::QDeclarative1OpenMetaObjectType(const QMetaObje
 QDeclarative1OpenMetaObjectType::~QDeclarative1OpenMetaObjectType()
 {
     if (d->mem)
-        qFree(d->mem);
+        free(d->mem);
     if (d->cache)
         d->cache->release();
     delete d;
@@ -100,7 +100,7 @@ int QDeclarative1OpenMetaObjectType::createProperty(const QByteArray &name)
     d->mob.addSignal("__" + QByteArray::number(id) + "()");
     QMetaPropertyBuilder build = d->mob.addProperty(name, "QVariant", id);
     propertyCreated(id, build);
-    qFree(d->mem);
+    free(d->mem);
     d->mem = d->mob.toMetaObject();
     d->names.insert(name, id);
     QSet<QDeclarative1OpenMetaObject*>::iterator it = d->referers.begin();
index 89e611c..66c26dd 100644 (file)
@@ -82,7 +82,7 @@ public:
     {
         if (propertyCache)
             propertyCache->release();
-        qFree(metaObject);
+        free(metaObject);
     }
 
     QMetaObject *metaObject;
@@ -642,7 +642,7 @@ public:
         }
 
         if (m_type->metaObject)
-            qFree(m_type->metaObject);
+            free(m_type->metaObject);
         m_type->metaObject = m_type->builder.toMetaObject();
         *static_cast<QMetaObject *>(this) = *m_type->metaObject;
 
index d5e6042..3de1e91 100644 (file)
@@ -1301,7 +1301,7 @@ QQuickVisualDataModelItemMetaType::QQuickVisualDataModelItemMetaType(
 
 QQuickVisualDataModelItemMetaType::~QQuickVisualDataModelItemMetaType()
 {
-    qFree(metaObject);
+    free(metaObject);
     qPersistentDispose(constructor);
 }
 
index b747bb9..311ee9b 100644 (file)
@@ -183,7 +183,7 @@ QSGGeometry::QSGGeometry(const QSGGeometry::AttributeSet &attributes,
 QSGGeometry::~QSGGeometry()
 {
     if (m_owns_data)
-        qFree(m_data);
+        free(m_data);
 
     if (m_server_data)
         delete m_server_data;
@@ -311,7 +311,7 @@ void QSGGeometry::allocate(int vertexCount, int indexCount)
     int vertexByteSize = m_attributes.stride * m_vertex_count;
 
     if (m_owns_data)
-        qFree(m_data);
+        free(m_data);
 
     if (canUsePrealloc && vertexByteSize <= (int) sizeof(m_prealloc)) {
         m_data = (void *) &m_prealloc[0];
@@ -320,7 +320,7 @@ void QSGGeometry::allocate(int vertexCount, int indexCount)
     } else {
         Q_ASSERT(m_index_type == GL_UNSIGNED_INT || m_index_type == GL_UNSIGNED_SHORT);
         int indexByteSize = indexCount * (m_index_type == GL_UNSIGNED_SHORT ? sizeof(quint16) : sizeof(quint32));
-        m_data = (void *) qMalloc(vertexByteSize + indexByteSize);
+        m_data = (void *) malloc(vertexByteSize + indexByteSize);
         m_index_data_offset = vertexByteSize;
         m_owns_data = true;
     }
index 9e851bf..4b9f401 100644 (file)
@@ -440,7 +440,7 @@ inline PathSimplifier::ElementAllocator::~ElementAllocator()
     while (blocks) {
         ElementBlock *block = blocks;
         blocks = blocks->next;
-        qFree(block);
+        free(block);
     }
 }
 
@@ -448,7 +448,7 @@ inline void PathSimplifier::ElementAllocator::allocate(int count)
 {
     Q_ASSERT(blocks == 0);
     Q_ASSERT(count > 0);
-    blocks = (ElementBlock *)qMalloc(sizeof(ElementBlock) + (count - 1) * sizeof(Element));
+    blocks = (ElementBlock *)malloc(sizeof(ElementBlock) + (count - 1) * sizeof(Element));
     blocks->blockSize = count;
     blocks->next = 0;
     blocks->firstFree = 0;
@@ -460,7 +460,7 @@ inline PathSimplifier::Element *PathSimplifier::ElementAllocator::newElement()
     if (blocks->firstFree < blocks->blockSize)
         return &blocks->elements[blocks->firstFree++];
     ElementBlock *oldBlock = blocks;
-    blocks = (ElementBlock *)qMalloc(sizeof(ElementBlock) + (oldBlock->blockSize - 1) * sizeof(Element));
+    blocks = (ElementBlock *)malloc(sizeof(ElementBlock) + (oldBlock->blockSize - 1) * sizeof(Element));
     blocks->blockSize = oldBlock->blockSize;
     blocks->next = oldBlock;
     blocks->firstFree = 0;