Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/text/qfragmentmap_p.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    215215template <class Fragment>
    216216QFragmentMapData<Fragment>::QFragmentMapData()
     217    : fragments(0)
    217218{
    218219    init();
     
    222223void QFragmentMapData<Fragment>::init()
    223224{
    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
    225234    head->tag = (((quint32)'p') << 24) | (((quint32)'m') << 16) | (((quint32)'a') << 8) | 'p'; //TAG('p', 'm', 'a', 'p');
    226235    head->root = 0;
    227236    head->freelist = 1;
    228237    head->node_count = 0;
    229     head->allocated = 64;
    230238    // mark all items to the right as unused
    231239    F(head->freelist).right = 0;
     
    235243QFragmentMapData<Fragment>::~QFragmentMapData()
    236244{
    237     free(head);
     245    free(fragments);
    238246}
    239247
     
    248256        uint needed = qAllocMore((freePos+1)*fragmentSize, 0);
    249257        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;
    251261        head->allocated = needed/fragmentSize;
    252262        F(freePos).right = 0;
     
    788798    ~QFragmentMap()
    789799    {
     800        if (!data.fragments)
     801            return; // in case of out-of-memory, we won't have fragments
    790802        for (Iterator it = begin(); !it.atEnd(); ++it)
    791803            it.value()->free();
     
    795807        for (Iterator it = begin(); !it.atEnd(); ++it)
    796808            it.value()->free();
    797         ::free(data.head);
    798809        data.init();
    799810    }
Note: See TracChangeset for help on using the changeset viewer.