summaryrefslogtreecommitdiff
path: root/qmake/tools/qgvector.cpp
Side-by-side diff
Diffstat (limited to 'qmake/tools/qgvector.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/tools/qgvector.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/qmake/tools/qgvector.cpp b/qmake/tools/qgvector.cpp
index 1985f03..3c903ed 100644
--- a/qmake/tools/qgvector.cpp
+++ b/qmake/tools/qgvector.cpp
@@ -14,48 +14,54 @@
** LICENSE.QPL included in the packaging of this file.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
** licenses may use this file in accordance with the Qt Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
+#include "qglobal.h"
+#if defined(Q_CC_BOR)
+// needed for qsort() because of a std namespace problem on Borland
+#include "qplatformdefs.h"
+#endif
+
#define QGVECTOR_CPP
#include "qgvector.h"
#include "qglist.h"
#include "qstring.h"
#include "qdatastream.h"
#include <stdlib.h>
#ifdef QT_THREAD_SUPPORT
# include <private/qmutexpool_p.h>
#endif // QT_THREAD_SUPPORT
#define USE_MALLOC // comment to use new/delete
#undef NEW
#undef DELETE
#if defined(USE_MALLOC)
#define NEW(type,size) ((type*)malloc(size*sizeof(type)))
#define DELETE(array) (free((char*)array))
#else
#define NEW(type,size) (new type[size])
#define DELETE(array) (delete[] array)
#define DONT_USE_REALLOC // comment to use realloc()
#endif
@@ -372,49 +378,50 @@ static int cmp_vec( const void *n1, const void *n2 )
void QGVector::sort() // sort vector
{
if ( count() == 0 ) // no elements
return;
register Item *start = &vec[0];
register Item *end = &vec[len-1];
Item tmp;
for (;;) { // put all zero elements behind
while ( start < end && *start != 0 )
start++;
while ( end > start && *end == 0 )
end--;
if ( start < end ) {
tmp = *start;
*start = *end;
*end = tmp;
} else {
break;
}
}
#ifdef QT_THREAD_SUPPORT
- QMutexLocker locker( qt_global_mutexpool->get( &sort_vec ) );
+ QMutexLocker locker( qt_global_mutexpool ?
+ qt_global_mutexpool->get( &sort_vec ) : 0 );
#endif // QT_THREAD_SUPPORT
sort_vec = (QGVector*)this;
qsort( vec, count(), sizeof(Item), cmp_vec );
sort_vec = 0;
}
int QGVector::bsearch( Item d ) const // binary search; when sorted
{
if ( !len )
return -1;
if ( !d ) {
#if defined(QT_CHECK_NULL)
qWarning( "QGVector::bsearch: Cannot search for null object" );
#endif
return -1;
}
int n1 = 0;
int n2 = len - 1;
int mid = 0;
bool found = FALSE;
while ( n1 <= n2 ) {
int res;
mid = (n1 + n2)/2;