Changeset 561 for trunk/src/gui/text/qfragmentmap_p.h
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/text/qfragmentmap_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 215 215 template <class Fragment> 216 216 QFragmentMapData<Fragment>::QFragmentMapData() 217 : fragments(0) 217 218 { 218 219 init(); … … 222 223 void QFragmentMapData<Fragment>::init() 223 224 { 224 fragments = (Fragment *)malloc(64*fragmentSize); 225 // the following code will realloc an existing fragment or create a new one. 226 // it will also ignore errors when shrinking an existing fragment. 227 Fragment *newFragments = (Fragment *)realloc(fragments, 64*fragmentSize); 228 if (newFragments) { 229 fragments = newFragments; 230 head->allocated = 64; 231 } 232 Q_CHECK_PTR(fragments); 233 225 234 head->tag = (((quint32)'p') << 24) | (((quint32)'m') << 16) | (((quint32)'a') << 8) | 'p'; //TAG('p', 'm', 'a', 'p'); 226 235 head->root = 0; 227 236 head->freelist = 1; 228 237 head->node_count = 0; 229 head->allocated = 64;230 238 // mark all items to the right as unused 231 239 F(head->freelist).right = 0; … … 235 243 QFragmentMapData<Fragment>::~QFragmentMapData() 236 244 { 237 free( head);245 free(fragments); 238 246 } 239 247 … … 248 256 uint needed = qAllocMore((freePos+1)*fragmentSize, 0); 249 257 Q_ASSERT(needed/fragmentSize > head->allocated); 250 fragments = (Fragment *)realloc(fragments, needed); 258 Fragment *newFragments = (Fragment *)realloc(fragments, needed); 259 Q_CHECK_PTR(newFragments); 260 fragments = newFragments; 251 261 head->allocated = needed/fragmentSize; 252 262 F(freePos).right = 0; … … 788 798 ~QFragmentMap() 789 799 { 800 if (!data.fragments) 801 return; // in case of out-of-memory, we won't have fragments 790 802 for (Iterator it = begin(); !it.atEnd(); ++it) 791 803 it.value()->free(); … … 795 807 for (Iterator it = begin(); !it.atEnd(); ++it) 796 808 it.value()->free(); 797 ::free(data.head);798 809 data.init(); 799 810 }
Note:
See TracChangeset
for help on using the changeset viewer.