diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-03-21 10:21:03 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-03-21 12:08:32 +0100 |
commit | 176ba743c12ecbfdda71522062f6d1a5749f3756 (patch) | |
tree | f8c5219f7010560556c7c07e44c0c14b144163f0 /sw | |
parent | 2a1171929e221ec689d2b8b6ac473d91b53b6286 (diff) |
BigPtrArray: deploy some asserts
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/bparr.hxx | 8 | ||||
-rw-r--r-- | sw/source/core/bastyp/bparr.cxx | 16 |
2 files changed, 12 insertions, 12 deletions
diff --git a/sw/inc/bparr.hxx b/sw/inc/bparr.hxx index cd95b1c75ed8..a2834d3bb06a 100644 --- a/sw/inc/bparr.hxx +++ b/sw/inc/bparr.hxx @@ -26,8 +26,10 @@ * ************************************************************************/ -#ifndef _BPARR_HXX -#define _BPARR_HXX +#ifndef SW_BPARR_HXX +#define SW_BPARR_HXX + +#include <assert.h> #include <tools/solar.h> #include <osl/diagnose.h> @@ -113,7 +115,7 @@ public: inline sal_uLong BigPtrEntry::GetPos() const { - OSL_ENSURE( this == pBlock->pData[ nOffset ], "element not in the block" ); + assert(this == pBlock->pData[ nOffset ]); // element not in the block return pBlock->nStart + nOffset; } diff --git a/sw/source/core/bastyp/bparr.cxx b/sw/source/core/bastyp/bparr.cxx index ef921030a4e0..561e334231c2 100644 --- a/sw/source/core/bastyp/bparr.cxx +++ b/sw/source/core/bastyp/bparr.cxx @@ -43,18 +43,16 @@ const sal_uInt16 nBlockGrowSize = 20; void CheckIdx( BlockInfo** ppInf, sal_uInt16 nBlock, sal_uLong nSize, sal_uInt16 nCur ) { - OSL_ENSURE( !nSize || nCur < nBlock, "BigPtrArray: CurIndex steht falsch" ); + assert(!nSize || nCur < nBlock); // BigPtrArray: CurIndex invalid sal_uLong nIdx = 0; for( sal_uInt16 nCnt = 0; nCnt < nBlock; ++nCnt, ++ppInf ) { nIdx += (*ppInf)->nElem; - // Array mit Luecken darf es nicht geben - OSL_ENSURE( !nCnt || (*(ppInf-1))->nEnd + 1 == (*ppInf)->nStart, - "BigPtrArray: Luecke in der Verwaltung!" ); + // Array with holes is not allowed + assert(!nCnt || (*(ppInf-1))->nEnd + 1 == (*ppInf)->nStart); } - - OSL_ENSURE( nIdx == nSize, "BigPtrArray: Anzahl ungueltig" ); + assert(nIdx == nSize); // invalid count in nSize } #else @@ -137,8 +135,8 @@ void BigPtrArray::ForEach( sal_uLong nStart, sal_uLong nEnd, ElementPtr BigPtrArray::operator[]( sal_uLong idx ) const { + assert(idx < nSize); // operator[]: Index out of bounds // weil die Funktion eben doch nicht const ist: - OSL_ENSURE( idx < nSize, "operator[]: Index aussserhalb" ); BigPtrArray* pThis = (BigPtrArray*) this; sal_uInt16 cur = Index2Block( idx ); BlockInfo* p = ppInf[ cur ]; @@ -349,7 +347,7 @@ void BigPtrArray::Insert( const ElementPtr& rElem, sal_uLong pos ) } // Nun haben wir einen freien Block am Wickel: eintragen pos -= p->nStart; - OSL_ENSURE( pos < MAXENTRY, "falsche Pos" ); + assert(pos < MAXENTRY); if( pos != p->nElem ) { int nCount = p->nElem - sal_uInt16(pos); @@ -458,8 +456,8 @@ void BigPtrArray::Remove( sal_uLong pos, sal_uLong n ) void BigPtrArray::Replace( sal_uLong idx, const ElementPtr& rElem) { + assert(idx < nSize); // Index out of bounds // weil die Funktion eben doch nicht const ist: - OSL_ENSURE( idx < nSize, "Set: Index aussserhalb" ); BigPtrArray* pThis = (BigPtrArray*) this; sal_uInt16 cur = Index2Block( idx ); BlockInfo* p = ppInf[ cur ]; |