-rw-r--r-- | qmake/tools/qgvector.cpp | 9 |
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 @@ | |||
14 | ** LICENSE.QPL included in the packaging of this file. | 14 | ** LICENSE.QPL included in the packaging of this file. |
15 | ** | 15 | ** |
16 | ** This file may be distributed and/or modified under the terms of the | 16 | ** This file may be distributed and/or modified under the terms of the |
17 | ** GNU General Public License version 2 as published by the Free Software | 17 | ** GNU General Public License version 2 as published by the Free Software |
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 18 | ** Foundation and appearing in the file LICENSE.GPL included in the |
19 | ** packaging of this file. | 19 | ** packaging of this file. |
20 | ** | 20 | ** |
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition |
22 | ** licenses may use this file in accordance with the Qt Commercial License | 22 | ** licenses may use this file in accordance with the Qt Commercial License |
23 | ** Agreement provided with the Software. | 23 | ** Agreement provided with the Software. |
24 | ** | 24 | ** |
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
27 | ** | 27 | ** |
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
29 | ** information about Qt Commercial License Agreements. | 29 | ** information about Qt Commercial License Agreements. |
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
32 | ** | 32 | ** |
33 | ** Contact info@trolltech.com if any conditions of this licensing are | 33 | ** Contact info@trolltech.com if any conditions of this licensing are |
34 | ** not clear to you. | 34 | ** not clear to you. |
35 | ** | 35 | ** |
36 | **********************************************************************/ | 36 | **********************************************************************/ |
37 | 37 | ||
38 | #include "qglobal.h" | ||
39 | #if defined(Q_CC_BOR) | ||
40 | // needed for qsort() because of a std namespace problem on Borland | ||
41 | #include "qplatformdefs.h" | ||
42 | #endif | ||
43 | |||
38 | #define QGVECTOR_CPP | 44 | #define QGVECTOR_CPP |
39 | #include "qgvector.h" | 45 | #include "qgvector.h" |
40 | #include "qglist.h" | 46 | #include "qglist.h" |
41 | #include "qstring.h" | 47 | #include "qstring.h" |
42 | #include "qdatastream.h" | 48 | #include "qdatastream.h" |
43 | #include <stdlib.h> | 49 | #include <stdlib.h> |
44 | 50 | ||
45 | #ifdef QT_THREAD_SUPPORT | 51 | #ifdef QT_THREAD_SUPPORT |
46 | # include <private/qmutexpool_p.h> | 52 | # include <private/qmutexpool_p.h> |
47 | #endif // QT_THREAD_SUPPORT | 53 | #endif // QT_THREAD_SUPPORT |
48 | 54 | ||
49 | #define USE_MALLOC // comment to use new/delete | 55 | #define USE_MALLOC // comment to use new/delete |
50 | 56 | ||
51 | #undef NEW | 57 | #undef NEW |
52 | #undef DELETE | 58 | #undef DELETE |
53 | 59 | ||
54 | #if defined(USE_MALLOC) | 60 | #if defined(USE_MALLOC) |
55 | #define NEW(type,size)((type*)malloc(size*sizeof(type))) | 61 | #define NEW(type,size)((type*)malloc(size*sizeof(type))) |
56 | #define DELETE(array)(free((char*)array)) | 62 | #define DELETE(array)(free((char*)array)) |
57 | #else | 63 | #else |
58 | #define NEW(type,size)(new type[size]) | 64 | #define NEW(type,size)(new type[size]) |
59 | #define DELETE(array)(delete[] array) | 65 | #define DELETE(array)(delete[] array) |
60 | #define DONT_USE_REALLOC // comment to use realloc() | 66 | #define DONT_USE_REALLOC // comment to use realloc() |
61 | #endif | 67 | #endif |
@@ -372,49 +378,50 @@ static int cmp_vec( const void *n1, const void *n2 ) | |||
372 | 378 | ||
373 | 379 | ||
374 | void QGVector::sort() // sort vector | 380 | void QGVector::sort() // sort vector |
375 | { | 381 | { |
376 | if ( count() == 0 ) // no elements | 382 | if ( count() == 0 ) // no elements |
377 | return; | 383 | return; |
378 | register Item *start = &vec[0]; | 384 | register Item *start = &vec[0]; |
379 | register Item *end= &vec[len-1]; | 385 | register Item *end= &vec[len-1]; |
380 | Item tmp; | 386 | Item tmp; |
381 | for (;;) { // put all zero elements behind | 387 | for (;;) { // put all zero elements behind |
382 | while ( start < end && *start != 0 ) | 388 | while ( start < end && *start != 0 ) |
383 | start++; | 389 | start++; |
384 | while ( end > start && *end == 0 ) | 390 | while ( end > start && *end == 0 ) |
385 | end--; | 391 | end--; |
386 | if ( start < end ) { | 392 | if ( start < end ) { |
387 | tmp = *start; | 393 | tmp = *start; |
388 | *start = *end; | 394 | *start = *end; |
389 | *end = tmp; | 395 | *end = tmp; |
390 | } else { | 396 | } else { |
391 | break; | 397 | break; |
392 | } | 398 | } |
393 | } | 399 | } |
394 | 400 | ||
395 | #ifdef QT_THREAD_SUPPORT | 401 | #ifdef QT_THREAD_SUPPORT |
396 | QMutexLocker locker( qt_global_mutexpool->get( &sort_vec ) ); | 402 | QMutexLocker locker( qt_global_mutexpool ? |
403 | qt_global_mutexpool->get( &sort_vec ) : 0 ); | ||
397 | #endif // QT_THREAD_SUPPORT | 404 | #endif // QT_THREAD_SUPPORT |
398 | 405 | ||
399 | sort_vec = (QGVector*)this; | 406 | sort_vec = (QGVector*)this; |
400 | qsort( vec, count(), sizeof(Item), cmp_vec ); | 407 | qsort( vec, count(), sizeof(Item), cmp_vec ); |
401 | sort_vec = 0; | 408 | sort_vec = 0; |
402 | } | 409 | } |
403 | 410 | ||
404 | int QGVector::bsearch( Item d ) const // binary search; when sorted | 411 | int QGVector::bsearch( Item d ) const // binary search; when sorted |
405 | { | 412 | { |
406 | if ( !len ) | 413 | if ( !len ) |
407 | return -1; | 414 | return -1; |
408 | if ( !d ) { | 415 | if ( !d ) { |
409 | #if defined(QT_CHECK_NULL) | 416 | #if defined(QT_CHECK_NULL) |
410 | qWarning( "QGVector::bsearch: Cannot search for null object" ); | 417 | qWarning( "QGVector::bsearch: Cannot search for null object" ); |
411 | #endif | 418 | #endif |
412 | return -1; | 419 | return -1; |
413 | } | 420 | } |
414 | int n1 = 0; | 421 | int n1 = 0; |
415 | int n2 = len - 1; | 422 | int n2 = len - 1; |
416 | int mid = 0; | 423 | int mid = 0; |
417 | bool found = FALSE; | 424 | bool found = FALSE; |
418 | while ( n1 <= n2 ) { | 425 | while ( n1 <= n2 ) { |
419 | int res; | 426 | int res; |
420 | mid = (n1 + n2)/2; | 427 | mid = (n1 + n2)/2; |