diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2003-12-17 16:10:24 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2003-12-17 16:10:24 +0000 |
commit | 70158d12aa3be90e2c75e0b5853b9ef497ad26eb (patch) | |
tree | 0032b020c208a03ba22319fff92caefbb8392b64 /sal | |
parent | 0b3fff36abae515a832cb6ff12cb7d78fcf769d6 (diff) |
INTEGRATION: CWS geordi2q11 (1.4.200); FILE MERGED
2003/12/16 14:41:27 hr 1.4.200.1: #111934#: join CWS ooo111fix1
Diffstat (limited to 'sal')
-rw-r--r-- | sal/rtl/source/byteseq.c | 68 |
1 files changed, 45 insertions, 23 deletions
diff --git a/sal/rtl/source/byteseq.c b/sal/rtl/source/byteseq.c index fb77548249d4..3d0ec9dc048e 100644 --- a/sal/rtl/source/byteseq.c +++ b/sal/rtl/source/byteseq.c @@ -2,9 +2,9 @@ * * $RCSfile: byteseq.c,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: dbo $ $Date: 2002-04-26 09:12:54 $ + * last change: $Author: vg $ $Date: 2003-12-17 17:10:24 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,7 +93,8 @@ void SAL_CALL rtl_byte_sequence_reference2One( { pNew = (sal_Sequence *)rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE + nElements ); - rtl_copyMemory( pNew->elements, pSequence->elements, nElements ); + if ( pNew != 0 ) + rtl_copyMemory( pNew->elements, pSequence->elements, nElements ); if (! osl_decrementInterlockedCount( &pSequence->nRefCount )) rtl_freeMemory( pSequence ); @@ -103,8 +104,12 @@ void SAL_CALL rtl_byte_sequence_reference2One( pNew = (sal_Sequence *)rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE ); } - pNew->nRefCount = 1; - pNew->nElements = nElements; + if ( pNew != 0 ) + { + pNew->nRefCount = 1; + pNew->nElements = nElements; + } + *ppSequence = pNew; } } @@ -127,19 +132,21 @@ void SAL_CALL rtl_byte_sequence_realloc( { pNew = (sal_Sequence *)rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE + nSize ); - if (nSize > nElements) - { - rtl_copyMemory( pNew->elements, pSequence->elements, nElements ); - rtl_zeroMemory( pNew->elements + nElements, nSize - nElements ); - } - else + if ( pNew != 0 ) { - rtl_copyMemory( pNew->elements, pSequence->elements, nSize ); + if (nSize > nElements) + { + rtl_copyMemory( pNew->elements, pSequence->elements, nElements ); + rtl_zeroMemory( pNew->elements + nElements, nSize - nElements ); + } + else + { + rtl_copyMemory( pNew->elements, pSequence->elements, nSize ); + } } if (! osl_decrementInterlockedCount( &pSequence->nRefCount )) rtl_freeMemory( pSequence ); - pSequence = pNew; } else @@ -147,8 +154,13 @@ void SAL_CALL rtl_byte_sequence_realloc( pSequence = (sal_Sequence *)rtl_reallocateMemory( pSequence, SAL_SEQUENCE_HEADER_SIZE + nSize ); } - pSequence->nRefCount = 1; - pSequence->nElements = nSize; + + if ( pSequence != 0 ) + { + pSequence->nRefCount = 1; + pSequence->nElements = nSize; + } + *ppSequence = pSequence; } @@ -162,10 +174,12 @@ void SAL_CALL rtl_byte_sequence_acquire( sal_Sequence *pSequence ) //================================================================================================== void SAL_CALL rtl_byte_sequence_release( sal_Sequence *pSequence ) { - OSL_ASSERT( pSequence ); - if (! osl_decrementInterlockedCount( &(pSequence->nRefCount )) ) + if ( pSequence != 0 ) { - rtl_freeMemory( pSequence ); + if (! osl_decrementInterlockedCount( &(pSequence->nRefCount )) ) + { + rtl_freeMemory( pSequence ); + } } } @@ -183,8 +197,11 @@ void SAL_CALL rtl_byte_sequence_construct( sal_Sequence **ppSequence , sal_Int32 { *ppSequence = (sal_Sequence *) rtl_allocateZeroMemory( SAL_SEQUENCE_HEADER_SIZE + nLength ); - (*ppSequence)->nRefCount = 1; - (*ppSequence)->nElements = nLength; + if ( *ppSequence != 0 ) + { + (*ppSequence)->nRefCount = 1; + (*ppSequence)->nElements = nLength; + } } else { @@ -202,10 +219,14 @@ void SAL_CALL rtl_byte_sequence_constructNoDefault( sal_Sequence **ppSequence , rtl_byte_sequence_release( *ppSequence ); *ppSequence = 0; } + *ppSequence = (sal_Sequence *) rtl_allocateMemory( SAL_SEQUENCE_HEADER_SIZE + nLength ); - (*ppSequence)->nRefCount = 1; - (*ppSequence)->nElements = nLength; + if ( *ppSequence != 0 ) + { + (*ppSequence)->nRefCount = 1; + (*ppSequence)->nElements = nLength; + } } //================================================================================================== @@ -213,7 +234,8 @@ void SAL_CALL rtl_byte_sequence_constructFromArray( sal_Sequence **ppSequence, const sal_Int8 *pData , sal_Int32 nLength ) { rtl_byte_sequence_constructNoDefault( ppSequence , nLength ); - rtl_copyMemory( (*ppSequence)->elements, pData, nLength ); + if ( *ppSequence != 0 ) + rtl_copyMemory( (*ppSequence)->elements, pData, nLength ); } //================================================================================================== |