1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
25 #include <osl/diagnose.h>
26 #include <osl/interlck.h>
27 #include <typelib/typedescription.h>
29 #include <uno/sequence2.h>
42 static uno_Sequence
* reallocSeq(
43 uno_Sequence
* pReallocate
, std::size_t nElementSize
, sal_Int32 nElements
)
45 OSL_ASSERT( nElements
>= 0 );
46 uno_Sequence
* pNew
= nullptr;
47 sal_uInt32 nSize
= calcSeqMemSize( nElementSize
, nElements
);
50 if (pReallocate
== nullptr)
52 pNew
= static_cast<uno_Sequence
*>(std::malloc( nSize
));
56 pNew
= static_cast<uno_Sequence
*>(std::realloc( pReallocate
, nSize
));
62 pNew
->nElements
= nElements
;
69 static bool idefaultConstructElements(
70 uno_Sequence
** ppSeq
,
71 typelib_TypeDescriptionReference
* pElementType
,
72 sal_Int32 nStartIndex
, sal_Int32 nStopIndex
,
73 sal_Int32 nAlloc
) // >= 0 means (re)alloc memory for nAlloc elements
75 uno_Sequence
* pSeq
= *ppSeq
;
76 switch (pElementType
->eTypeClass
)
78 case typelib_TypeClass_CHAR
:
80 pSeq
= reallocSeq( pSeq
, sizeof(sal_Unicode
), nAlloc
);
84 pSeq
->elements
+ (sizeof(sal_Unicode
) * nStartIndex
),
86 sizeof(sal_Unicode
) * (nStopIndex
- nStartIndex
) );
89 case typelib_TypeClass_BOOLEAN
:
91 pSeq
= reallocSeq( pSeq
, sizeof(sal_Bool
), nAlloc
);
95 pSeq
->elements
+ (sizeof(sal_Bool
) * nStartIndex
),
97 sizeof(sal_Bool
) * (nStopIndex
- nStartIndex
) );
100 case typelib_TypeClass_BYTE
:
102 pSeq
= reallocSeq( pSeq
, sizeof(sal_Int8
), nAlloc
);
106 pSeq
->elements
+ (sizeof(sal_Int8
) * nStartIndex
),
108 sizeof(sal_Int8
) * (nStopIndex
- nStartIndex
) );
111 case typelib_TypeClass_SHORT
:
112 case typelib_TypeClass_UNSIGNED_SHORT
:
114 pSeq
= reallocSeq( pSeq
, sizeof(sal_Int16
), nAlloc
);
118 pSeq
->elements
+ (sizeof(sal_Int16
) * nStartIndex
),
120 sizeof(sal_Int16
) * (nStopIndex
- nStartIndex
) );
123 case typelib_TypeClass_LONG
:
124 case typelib_TypeClass_UNSIGNED_LONG
:
126 pSeq
= reallocSeq( pSeq
, sizeof(sal_Int32
), nAlloc
);
130 pSeq
->elements
+ (sizeof(sal_Int32
) * nStartIndex
),
132 sizeof(sal_Int32
) * (nStopIndex
- nStartIndex
) );
135 case typelib_TypeClass_HYPER
:
136 case typelib_TypeClass_UNSIGNED_HYPER
:
138 pSeq
= reallocSeq( pSeq
, sizeof(sal_Int64
), nAlloc
);
142 pSeq
->elements
+ (sizeof(sal_Int64
) * nStartIndex
),
144 sizeof(sal_Int64
) * (nStopIndex
- nStartIndex
) );
147 case typelib_TypeClass_FLOAT
:
150 pSeq
= reallocSeq( pSeq
, sizeof(float), nAlloc
);
153 float * pElements
= reinterpret_cast<float *>(pSeq
->elements
);
154 for ( sal_Int32 nPos
= nStartIndex
; nPos
< nStopIndex
; ++nPos
)
156 pElements
[nPos
] = 0.0;
161 case typelib_TypeClass_DOUBLE
:
164 pSeq
= reallocSeq( pSeq
, sizeof(double), nAlloc
);
167 double * pElements
= reinterpret_cast<double *>(pSeq
->elements
);
168 for ( sal_Int32 nPos
= nStartIndex
; nPos
< nStopIndex
; ++nPos
)
170 pElements
[nPos
] = 0.0;
175 case typelib_TypeClass_STRING
:
178 pSeq
= reallocSeq( pSeq
, sizeof(rtl_uString
*), nAlloc
);
181 rtl_uString
** pElements
= reinterpret_cast<rtl_uString
**>(pSeq
->elements
);
182 for ( sal_Int32 nPos
= nStartIndex
; nPos
< nStopIndex
; ++nPos
)
184 pElements
[nPos
] = nullptr;
185 rtl_uString_new( &pElements
[nPos
] );
190 case typelib_TypeClass_TYPE
:
195 pSeq
, sizeof(typelib_TypeDescriptionReference
*), nAlloc
);
199 typelib_TypeDescriptionReference
** pElements
=
200 reinterpret_cast<typelib_TypeDescriptionReference
**>(pSeq
->elements
);
201 for ( sal_Int32 nPos
= nStartIndex
; nPos
< nStopIndex
; ++nPos
)
203 pElements
[nPos
] = _getVoidType();
208 case typelib_TypeClass_ANY
:
211 pSeq
= reallocSeq( pSeq
, sizeof(uno_Any
), nAlloc
);
214 uno_Any
* pElements
= reinterpret_cast<uno_Any
*>(pSeq
->elements
);
215 for ( sal_Int32 nPos
= nStartIndex
; nPos
< nStopIndex
; ++nPos
)
217 CONSTRUCT_EMPTY_ANY( &pElements
[nPos
] );
222 case typelib_TypeClass_ENUM
:
225 pSeq
= reallocSeq( pSeq
, sizeof(sal_Int32
), nAlloc
);
228 typelib_TypeDescription
* pElementTypeDescr
= nullptr;
229 TYPELIB_DANGER_GET( &pElementTypeDescr
, pElementType
);
231 reinterpret_cast<typelib_EnumTypeDescription
*>(
232 pElementTypeDescr
)->nDefaultEnumValue
;
233 TYPELIB_DANGER_RELEASE( pElementTypeDescr
);
235 sal_Int32
* pElements
= reinterpret_cast<sal_Int32
*>(pSeq
->elements
);
236 for ( sal_Int32 nPos
= nStartIndex
; nPos
< nStopIndex
; ++nPos
)
238 pElements
[nPos
] = eEnum
;
243 case typelib_TypeClass_STRUCT
:
244 case typelib_TypeClass_EXCEPTION
:
246 typelib_TypeDescription
* pElementTypeDescr
= nullptr;
247 TYPELIB_DANGER_GET( &pElementTypeDescr
, pElementType
);
248 sal_Int32 nElementSize
= pElementTypeDescr
->nSize
;
251 pSeq
= reallocSeq( pSeq
, nElementSize
, nAlloc
);
254 char * pElements
= pSeq
->elements
;
255 for ( sal_Int32 nPos
= nStartIndex
; nPos
< nStopIndex
; ++nPos
)
257 _defaultConstructStruct(
258 pElements
+ (nElementSize
* nPos
),
259 reinterpret_cast<typelib_CompoundTypeDescription
*>(pElementTypeDescr
) );
263 TYPELIB_DANGER_RELEASE( pElementTypeDescr
);
266 case typelib_TypeClass_SEQUENCE
:
270 // coverity[suspicious_sizeof : FALSE] - sizeof(uno_Sequence*) is correct here
271 pSeq
= reallocSeq(pSeq
, sizeof(uno_Sequence
*), nAlloc
);
275 uno_Sequence
** pElements
=
276 reinterpret_cast<uno_Sequence
**>(pSeq
->elements
);
277 for ( sal_Int32 nPos
= nStartIndex
; nPos
< nStopIndex
; ++nPos
)
279 pElements
[nPos
] = createEmptySequence();
284 case typelib_TypeClass_INTERFACE
: // either C++ or C-UNO interface
286 pSeq
= reallocSeq( pSeq
, sizeof(void *), nAlloc
);
290 pSeq
->elements
+ (sizeof(void *) * nStartIndex
),
292 sizeof(void *) * (nStopIndex
- nStartIndex
) );
296 OSL_FAIL( "### unexpected element type!" );
303 OSL_ASSERT( nAlloc
>= 0 ); // must have been an allocation failure
310 // coverity[ -tainted_data_sink : arg-1 ]
311 static bool icopyConstructFromElements(
312 uno_Sequence
** ppSeq
, void * pSourceElements
,
313 typelib_TypeDescriptionReference
* pElementType
,
314 sal_Int32 nStopIndex
,
315 uno_AcquireFunc acquire
,
318 uno_Sequence
* pSeq
= *ppSeq
;
319 switch (pElementType
->eTypeClass
)
321 case typelib_TypeClass_CHAR
:
322 pSeq
= reallocSeq( pSeq
, sizeof(sal_Unicode
), nAlloc
);
328 sizeof(sal_Unicode
) * nStopIndex
);
331 case typelib_TypeClass_BOOLEAN
:
332 pSeq
= reallocSeq( pSeq
, sizeof(sal_Bool
), nAlloc
);
338 sizeof(sal_Bool
) * nStopIndex
);
341 case typelib_TypeClass_BYTE
:
342 pSeq
= reallocSeq( pSeq
, sizeof(sal_Int8
), nAlloc
);
348 sizeof(sal_Int8
) * nStopIndex
);
351 case typelib_TypeClass_SHORT
:
352 case typelib_TypeClass_UNSIGNED_SHORT
:
353 pSeq
= reallocSeq( pSeq
, sizeof(sal_Int16
), nAlloc
);
359 sizeof(sal_Int16
) * nStopIndex
);
362 case typelib_TypeClass_LONG
:
363 case typelib_TypeClass_UNSIGNED_LONG
:
364 pSeq
= reallocSeq( pSeq
, sizeof(sal_Int32
), nAlloc
);
370 sizeof(sal_Int32
) * nStopIndex
);
373 case typelib_TypeClass_HYPER
:
374 case typelib_TypeClass_UNSIGNED_HYPER
:
375 pSeq
= reallocSeq( pSeq
, sizeof(sal_Int64
), nAlloc
);
381 sizeof(sal_Int64
) * nStopIndex
);
384 case typelib_TypeClass_FLOAT
:
385 pSeq
= reallocSeq( pSeq
, sizeof(float), nAlloc
);
391 sizeof(float) * nStopIndex
);
394 case typelib_TypeClass_DOUBLE
:
395 pSeq
= reallocSeq( pSeq
, sizeof(double), nAlloc
);
401 sizeof(double) * nStopIndex
);
404 case typelib_TypeClass_ENUM
:
405 pSeq
= reallocSeq( pSeq
, sizeof(sal_Int32
), nAlloc
);
411 sizeof(sal_Int32
) * nStopIndex
);
414 case typelib_TypeClass_STRING
:
416 pSeq
= reallocSeq( pSeq
, sizeof(rtl_uString
*), nAlloc
);
419 rtl_uString
** pDestElements
= reinterpret_cast<rtl_uString
**>(pSeq
->elements
);
420 for ( sal_Int32 nPos
= 0; nPos
< nStopIndex
; ++nPos
)
422 // This code tends to trigger coverity's overrun-buffer-arg warning
423 // coverity[index_parm_via_loop_bound] - https://communities.coverity.com/thread/2993
424 ::rtl_uString_acquire(
425 static_cast<rtl_uString
**>(pSourceElements
)[nPos
] );
426 pDestElements
[nPos
] = static_cast<rtl_uString
**>(pSourceElements
)[nPos
];
431 case typelib_TypeClass_TYPE
:
434 pSeq
, sizeof(typelib_TypeDescriptionReference
*), nAlloc
);
437 typelib_TypeDescriptionReference
** pDestElements
=
438 reinterpret_cast<typelib_TypeDescriptionReference
**>(pSeq
->elements
);
439 for ( sal_Int32 nPos
= 0; nPos
< nStopIndex
; ++nPos
)
442 static_cast<typelib_TypeDescriptionReference
**>(
443 pSourceElements
)[nPos
] );
444 pDestElements
[nPos
] =
445 static_cast<typelib_TypeDescriptionReference
**>(
446 pSourceElements
)[nPos
];
451 case typelib_TypeClass_ANY
:
453 pSeq
= reallocSeq( pSeq
, sizeof(uno_Any
), nAlloc
);
456 uno_Any
* pDestElements
= reinterpret_cast<uno_Any
*>(pSeq
->elements
);
457 for ( sal_Int32 nPos
= 0; nPos
< nStopIndex
; ++nPos
)
459 uno_Any
* pSource
= static_cast<uno_Any
*>(pSourceElements
) + nPos
;
461 &pDestElements
[nPos
],
463 pSource
->pType
, nullptr,
469 case typelib_TypeClass_STRUCT
:
470 case typelib_TypeClass_EXCEPTION
:
472 typelib_TypeDescription
* pElementTypeDescr
= nullptr;
473 TYPELIB_DANGER_GET( &pElementTypeDescr
, pElementType
);
474 sal_Int32 nElementSize
= pElementTypeDescr
->nSize
;
476 pSeq
= reallocSeq( pSeq
, nElementSize
, nAlloc
);
479 char * pDestElements
= pSeq
->elements
;
481 typelib_CompoundTypeDescription
* pTypeDescr
=
482 reinterpret_cast<typelib_CompoundTypeDescription
*>(pElementTypeDescr
);
483 for ( sal_Int32 nPos
= 0; nPos
< nStopIndex
; ++nPos
)
486 pDestElements
+ (nElementSize
* nPos
);
488 static_cast<char *>(pSourceElements
) + (nElementSize
* nPos
);
490 if (pTypeDescr
->pBaseTypeDescription
)
493 _copyConstructStruct(
495 pTypeDescr
->pBaseTypeDescription
, acquire
, nullptr );
499 typelib_TypeDescriptionReference
** ppTypeRefs
=
500 pTypeDescr
->ppTypeRefs
;
501 sal_Int32
* pMemberOffsets
= pTypeDescr
->pMemberOffsets
;
502 sal_Int32 nDescr
= pTypeDescr
->nMembers
;
507 pDest
+ pMemberOffsets
[nDescr
],
508 pSource
+ pMemberOffsets
[nDescr
],
509 ppTypeRefs
[nDescr
], acquire
);
514 TYPELIB_DANGER_RELEASE( pElementTypeDescr
);
517 case typelib_TypeClass_SEQUENCE
: // sequence of sequence
519 // coverity[suspicious_sizeof : FALSE] - sizeof(uno_Sequence*) is correct here
520 pSeq
= reallocSeq(pSeq
, sizeof(uno_Sequence
*), nAlloc
);
523 typelib_TypeDescription
* pElementTypeDescr
= nullptr;
524 TYPELIB_DANGER_GET( &pElementTypeDescr
, pElementType
);
525 typelib_TypeDescriptionReference
* pSeqElementType
=
526 reinterpret_cast<typelib_IndirectTypeDescription
*>(pElementTypeDescr
)->pType
;
527 uno_Sequence
** pDestElements
= reinterpret_cast<uno_Sequence
**>(pSeq
->elements
);
528 for ( sal_Int32 nPos
= 0; nPos
< nStopIndex
; ++nPos
)
530 uno_Sequence
* pNew
= icopyConstructSequence(
531 static_cast<uno_Sequence
**>(pSourceElements
)[nPos
],
532 pSeqElementType
, acquire
, nullptr );
533 OSL_ASSERT( pNew
!= nullptr );
534 // ought never be a memory allocation problem,
535 // because of reference counted sequence handles
536 pDestElements
[ nPos
] = pNew
;
538 TYPELIB_DANGER_RELEASE( pElementTypeDescr
);
542 case typelib_TypeClass_INTERFACE
:
544 pSeq
= reallocSeq( pSeq
, sizeof(void *), nAlloc
);
547 void ** pDestElements
= reinterpret_cast<void **>(pSeq
->elements
);
548 for ( sal_Int32 nPos
= 0; nPos
< nStopIndex
; ++nPos
)
550 pDestElements
[nPos
] = static_cast<void **>(pSourceElements
)[nPos
];
551 _acquire( pDestElements
[nPos
], acquire
);
557 OSL_FAIL( "### unexpected element type!" );
564 return false; // allocation failure
571 static bool ireallocSequence(
572 uno_Sequence
** ppSequence
,
573 typelib_TypeDescriptionReference
* pElementType
,
575 uno_AcquireFunc acquire
, uno_ReleaseFunc release
)
578 uno_Sequence
* pSeq
= *ppSequence
;
579 sal_Int32 nElements
= pSeq
->nElements
;
581 if (pSeq
->nRefCount
> 1 ||
582 // not mem-copyable elements?
583 typelib_TypeClass_ANY
== pElementType
->eTypeClass
||
584 typelib_TypeClass_STRUCT
== pElementType
->eTypeClass
||
585 typelib_TypeClass_EXCEPTION
== pElementType
->eTypeClass
)
587 // split sequence and construct new one from scratch
588 uno_Sequence
* pNew
= nullptr;
590 sal_Int32 nRest
= nSize
- nElements
;
591 sal_Int32 nCopy
= (nRest
> 0 ? nElements
: nSize
);
595 ret
= icopyConstructFromElements(
596 &pNew
, pSeq
->elements
, pElementType
,
598 nSize
); // alloc to nSize
600 if (ret
&& nRest
> 0)
602 ret
= idefaultConstructElements(
605 nCopy
>= 0 ? -1 /* no mem allocation */ : nSize
);
611 if (osl_atomic_decrement( &pSeq
->nRefCount
) == 0)
616 pSeq
->elements
, pElementType
,
617 0, nElements
, release
);
626 OSL_ASSERT( pSeq
->nRefCount
== 1 );
627 if (nSize
> nElements
) // default construct the rest
629 ret
= idefaultConstructElements(
630 ppSequence
, pElementType
,
632 nSize
); // realloc to nSize
634 else // or destruct the rest and realloc mem
636 sal_Int32 nElementSize
= idestructElements(
637 pSeq
->elements
, pElementType
,
638 nSize
, nElements
, release
);
639 // warning: it is assumed that the following will never fail,
640 // else this leads to a sequence null handle
641 *ppSequence
= reallocSeq( pSeq
, nElementSize
, nSize
);
642 OSL_ASSERT( *ppSequence
!= nullptr );
643 ret
= (*ppSequence
!= nullptr);
655 sal_Bool SAL_CALL
uno_type_sequence_construct(
656 uno_Sequence
** ppSequence
, typelib_TypeDescriptionReference
* pType
,
657 void * pElements
, sal_Int32 len
,
658 uno_AcquireFunc acquire
)
665 typelib_TypeDescription
* pTypeDescr
= nullptr;
666 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
668 typelib_TypeDescriptionReference
* pElementType
=
669 reinterpret_cast<typelib_IndirectTypeDescription
*>(pTypeDescr
)->pType
;
671 *ppSequence
= nullptr;
672 if (pElements
== nullptr)
674 ret
= idefaultConstructElements(
675 ppSequence
, pElementType
,
677 len
); // alloc to len
681 ret
= icopyConstructFromElements(
682 ppSequence
, pElements
, pElementType
,
684 len
); // alloc to len
687 TYPELIB_DANGER_RELEASE( pTypeDescr
);
691 *ppSequence
= createEmptySequence();
695 OSL_ASSERT( (*ppSequence
!= nullptr) == ret
);
700 sal_Bool SAL_CALL
uno_sequence_construct(
701 uno_Sequence
** ppSequence
, typelib_TypeDescription
* pTypeDescr
,
702 void * pElements
, sal_Int32 len
,
703 uno_AcquireFunc acquire
)
709 typelib_TypeDescriptionReference
* pElementType
=
710 reinterpret_cast<typelib_IndirectTypeDescription
*>(pTypeDescr
)->pType
;
712 *ppSequence
= nullptr;
713 if (pElements
== nullptr)
715 ret
= idefaultConstructElements(
716 ppSequence
, pElementType
,
718 len
); // alloc to len
722 ret
= icopyConstructFromElements(
723 ppSequence
, pElements
, pElementType
,
725 len
); // alloc to len
730 *ppSequence
= createEmptySequence();
734 OSL_ASSERT( (*ppSequence
!= nullptr) == ret
);
739 sal_Bool SAL_CALL
uno_type_sequence_realloc(
740 uno_Sequence
** ppSequence
, typelib_TypeDescriptionReference
* pType
,
741 sal_Int32 nSize
, uno_AcquireFunc acquire
, uno_ReleaseFunc release
)
744 assert(ppSequence
&& "### null ptr!");
745 assert(nSize
>= 0 && "### new size must be at least 0!");
748 if (nSize
!= (*ppSequence
)->nElements
)
750 typelib_TypeDescription
* pTypeDescr
= nullptr;
751 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
752 ret
= ireallocSequence(
753 ppSequence
, reinterpret_cast<typelib_IndirectTypeDescription
*>(pTypeDescr
)->pType
,
754 nSize
, acquire
, release
);
755 TYPELIB_DANGER_RELEASE( pTypeDescr
);
761 sal_Bool SAL_CALL
uno_sequence_realloc(
762 uno_Sequence
** ppSequence
, typelib_TypeDescription
* pTypeDescr
,
763 sal_Int32 nSize
, uno_AcquireFunc acquire
, uno_ReleaseFunc release
)
766 OSL_ENSURE( ppSequence
, "### null ptr!" );
767 OSL_ENSURE( nSize
>= 0, "### new size must be at least 0!" );
770 if (nSize
!= (*ppSequence
)->nElements
)
772 ret
= ireallocSequence(
773 ppSequence
, reinterpret_cast<typelib_IndirectTypeDescription
*>(pTypeDescr
)->pType
,
774 nSize
, acquire
, release
);
780 sal_Bool SAL_CALL
uno_type_sequence_reference2One(
781 uno_Sequence
** ppSequence
,
782 typelib_TypeDescriptionReference
* pType
,
783 uno_AcquireFunc acquire
, uno_ReleaseFunc release
)
786 OSL_ENSURE( ppSequence
, "### null ptr!" );
788 uno_Sequence
* pSequence
= *ppSequence
;
789 if (pSequence
->nRefCount
> 1)
791 uno_Sequence
* pNew
= nullptr;
792 if (pSequence
->nElements
> 0)
794 typelib_TypeDescription
* pTypeDescr
= nullptr;
795 TYPELIB_DANGER_GET( &pTypeDescr
, pType
);
797 ret
= icopyConstructFromElements(
798 &pNew
, pSequence
->elements
,
799 reinterpret_cast<typelib_IndirectTypeDescription
*>(pTypeDescr
)->pType
,
800 pSequence
->nElements
, acquire
,
801 pSequence
->nElements
); // alloc nElements
804 idestructSequence( *ppSequence
, pType
, pTypeDescr
, release
);
808 TYPELIB_DANGER_RELEASE( pTypeDescr
);
812 pNew
= allocSeq( 0, 0 );
813 ret
= (pNew
!= nullptr);
816 // easy destruction of empty sequence:
817 if (osl_atomic_decrement( &pSequence
->nRefCount
) == 0)
818 std::free( pSequence
);
827 sal_Bool SAL_CALL
uno_sequence_reference2One(
828 uno_Sequence
** ppSequence
,
829 typelib_TypeDescription
* pTypeDescr
,
830 uno_AcquireFunc acquire
, uno_ReleaseFunc release
)
833 OSL_ENSURE( ppSequence
, "### null ptr!" );
835 uno_Sequence
* pSequence
= *ppSequence
;
836 if (pSequence
->nRefCount
> 1)
838 uno_Sequence
* pNew
= nullptr;
839 if (pSequence
->nElements
> 0)
841 ret
= icopyConstructFromElements(
842 &pNew
, pSequence
->elements
,
843 reinterpret_cast<typelib_IndirectTypeDescription
*>(pTypeDescr
)->pType
,
844 pSequence
->nElements
, acquire
,
845 pSequence
->nElements
); // alloc nElements
849 pSequence
, pTypeDescr
->pWeakRef
, pTypeDescr
, release
);
855 pNew
= allocSeq( 0, 0 );
856 ret
= (pNew
!= nullptr);
859 // easy destruction of empty sequence:
860 if (osl_atomic_decrement( &pSequence
->nRefCount
) == 0)
861 std::free( pSequence
);
871 void SAL_CALL
uno_sequence_assign(
872 uno_Sequence
** ppDest
,
873 uno_Sequence
* pSource
,
874 typelib_TypeDescription
* pTypeDescr
,
875 uno_ReleaseFunc release
)
878 if (*ppDest
!= pSource
)
880 osl_atomic_increment( &pSource
->nRefCount
);
881 idestructSequence( *ppDest
, pTypeDescr
->pWeakRef
, pTypeDescr
, release
);
887 void SAL_CALL
uno_type_sequence_assign(
888 uno_Sequence
** ppDest
,
889 uno_Sequence
* pSource
,
890 typelib_TypeDescriptionReference
* pType
,
891 uno_ReleaseFunc release
)
894 if (*ppDest
!= pSource
)
896 osl_atomic_increment( &pSource
->nRefCount
);
897 idestructSequence( *ppDest
, pType
, nullptr, release
);
902 void uno_type_sequence_destroy(
903 uno_Sequence
* sequence
, typelib_TypeDescriptionReference
* type
,
904 uno_ReleaseFunc release
)
907 idestroySequence(sequence
, type
, nullptr, release
);
912 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */