diff options
author | Daniel Boelzle <dbo@openoffice.org> | 2001-07-06 10:06:23 +0000 |
---|---|---|
committer | Daniel Boelzle <dbo@openoffice.org> | 2001-07-06 10:06:23 +0000 |
commit | d9950e48687933af3919409d5349c49d2ab04358 (patch) | |
tree | 49ae2f4376d9001910cca864c93cfa163079b21e /cppu | |
parent | da2e39d5e44717898559ebb56e6c411823ec8ceb (diff) |
#89361# mem realloc anys
Diffstat (limited to 'cppu')
-rw-r--r-- | cppu/source/uno/sequence.cxx | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/cppu/source/uno/sequence.cxx b/cppu/source/uno/sequence.cxx index 93f08a9b39e1..c1a3d55b1f27 100644 --- a/cppu/source/uno/sequence.cxx +++ b/cppu/source/uno/sequence.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sequence.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ + * last change: $Author: dbo $ $Date: 2001-07-06 11:06:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -587,12 +587,15 @@ static inline void __reallocSequence( } else { + sal_Int32 nCorrect; if (nSize > nSourceElements) // default construct the rest { __defaultConstructElements( ppSequence, pElementType, nSourceElements, nSize, nSize ); // realloc to nSize + // correct nSourceElements any data pointer due to reallocation + nCorrect = nSourceElements; } else // or destruct the rest and realloc mem { @@ -602,6 +605,53 @@ static inline void __reallocSequence( *ppSequence = (uno_Sequence *)::rtl_reallocateMemory( *ppSequence, SAL_SEQUENCE_HEADER_SIZE + (nSize * nElementSize) ); (*ppSequence)->nElements = nSize; + // correct nSize any data pointer due to reallocation + nCorrect = nSize; + } + if (typelib_TypeClass_ANY == pElementType->eTypeClass) + { + // correct reallocated any array + uno_Any * pAnys = (uno_Any *)(*ppSequence)->elements; + while (nCorrect--) + { + uno_Any * pAny = pAnys + nCorrect; + switch (pAny->pType->eTypeClass) + { + case typelib_TypeClass_CHAR: + case typelib_TypeClass_BOOLEAN: + case typelib_TypeClass_BYTE: + case typelib_TypeClass_SHORT: + case typelib_TypeClass_UNSIGNED_SHORT: + case typelib_TypeClass_LONG: + case typelib_TypeClass_UNSIGNED_LONG: + case typelib_TypeClass_STRING: + case typelib_TypeClass_TYPE: + case typelib_TypeClass_ENUM: + case typelib_TypeClass_SEQUENCE: + case typelib_TypeClass_INTERFACE: + pAny->pData = &pAny->pReserved; + break; + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: + if (sizeof(void *) >= sizeof(sal_Int64)) + { + pAny->pData = &pAny->pReserved; + } + break; + case typelib_TypeClass_FLOAT: + if (sizeof(void *) >= sizeof(float)) + { + pAny->pData = &pAny->pReserved; + } + break; + case typelib_TypeClass_DOUBLE: + if (sizeof(void *) >= sizeof(double)) + { + pAny->pData = &pAny->pReserved; + } + break; + } + } } } } |