From b866f86191653a689ce74a3c13e93e3bc34947b7 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 8 Aug 2014 17:43:01 +0200 Subject: qsort and bsearch need different kinds of callback functions Change-Id: I4a661434c3a51169ec14336bb39a1d2ceeb139ad --- sfx2/source/control/objface.cxx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'sfx2/source') diff --git a/sfx2/source/control/objface.cxx b/sfx2/source/control/objface.cxx index 32c7e8e78a4e..6c263701cebc 100644 --- a/sfx2/source/control/objface.cxx +++ b/sfx2/source/control/objface.cxx @@ -35,20 +35,23 @@ #include #include -extern "C" -#ifdef WNT -int _cdecl -#else -int -#endif +extern "C" { -SfxCompareSlots_Impl( const void* pSmaller, const void* pBigger ) +static int SAL_CALL +SfxCompareSlots_qsort( const void* pSmaller, const void* pBigger ) { return ( (int) ((SfxSlot*)pSmaller)->GetSlotId() ) - ( (int) ((SfxSlot*)pBigger)->GetSlotId() ); } +static int SAL_CALL +SfxCompareSlots_bsearch( const void* pSmaller, const void* pBigger ) +{ + return ( (int) *((sal_uInt16*)pSmaller) ) - + ( (int) ((SfxSlot*)pBigger)->GetSlotId() ); +} +} struct SfxObjectUI_Impl { @@ -148,7 +151,7 @@ void SfxInterface::SetSlotMap( SfxSlot& rSlotMap, sal_uInt16 nSlotCount ) if ( !pIter->pNextSlot ) { // sort the SfxSlots by id - qsort( pSlots, nCount, sizeof(SfxSlot), SfxCompareSlots_Impl ); + qsort( pSlots, nCount, sizeof(SfxSlot), SfxCompareSlots_qsort ); // link masters and slaves sal_uInt16 nIter = 1; @@ -311,7 +314,7 @@ const SfxSlot* SfxInterface::GetSlot( sal_uInt16 nFuncId ) const // find the id using binary search void* p = bsearch( &nFuncId, pSlots, nCount, sizeof(SfxSlot), - SfxCompareSlots_Impl ); + SfxCompareSlots_bsearch ); if ( !p && pGenoType ) return pGenoType->GetSlot( nFuncId ); -- cgit