From 72bc76e67af99b69c37ae9678ff08aaa5567d2b9 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 23 Feb 2010 16:11:16 +0000 Subject: [PATCH] 2010-02-23 17:10 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/vm/dynlibhb.c ! casting for OS2 builds * harbour/src/rtl/hbinet.c ! added automatic WINSOCK initialization in HB_INETIFINFO() function * harbour/contrib/hbwin/olecore.c % small optimization in OLE method calls (use static buffer for message name) --- harbour/ChangeLog | 11 +++++++++++ harbour/contrib/hbwin/olecore.c | 11 +++++++---- harbour/src/rtl/hbinet.c | 7 +++++-- harbour/src/vm/dynlibhb.c | 2 +- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b8738baa6c..dc4ad27a19 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,17 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-02-23 17:10 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/src/vm/dynlibhb.c + ! casting for OS2 builds + + * harbour/src/rtl/hbinet.c + ! added automatic WINSOCK initialization in HB_INETIFINFO() function + + * harbour/contrib/hbwin/olecore.c + % small optimization in OLE method calls + (use static buffer for message name) + 2010-02-23 14:25 UTC+0100 Maurilio Longo (maurilio.longo@libero.it) * source/contrib/hbxpp/tthreadx.prg diff --git a/harbour/contrib/hbwin/olecore.c b/harbour/contrib/hbwin/olecore.c index 29e4ce2816..d5aee1a6e6 100644 --- a/harbour/contrib/hbwin/olecore.c +++ b/harbour/contrib/hbwin/olecore.c @@ -279,6 +279,11 @@ static wchar_t* AnsiToWide( const char* szString ) return szWide; } +static void AnsiToWideBuffer( const char* szString, wchar_t* szWide, int iLen ) +{ + MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, szString, -1, szWide, iLen ); + szWide[ iLen - 1 ] = '0'; +} static BSTR hb_oleItemToString( PHB_ITEM pItem ) { @@ -1346,7 +1351,7 @@ HB_FUNC( WIN_OLEAUTO___ONERROR ) { IDispatch* pDisp; const char* szMethod; - wchar_t* szMethodWide; + wchar_t szMethodWide[ HB_SYMBOL_NAME_LEN + 1 ]; OLECHAR* pMemberArray; DISPID dispid; DISPPARAMS dispparam; @@ -1365,7 +1370,7 @@ HB_FUNC( WIN_OLEAUTO___ONERROR ) return; szMethod = hb_itemGetSymbol( hb_stackBaseItem() )->szName; - szMethodWide = AnsiToWide( szMethod ); + AnsiToWideBuffer( szMethod, szMethodWide, ( int ) sizeof( szMethodWide ) ); /* Try property put */ @@ -1389,7 +1394,6 @@ HB_FUNC( WIN_OLEAUTO___ONERROR ) DISPATCH_PROPERTYPUT, &dispparam, NULL, &excep, &uiArgErr ); FreeParams( &dispparam ); - hb_xfree( szMethodWide ); /* assign method should return assigned value */ hb_itemReturn( hb_param( 1, HB_IT_ANY ) ); @@ -1406,7 +1410,6 @@ HB_FUNC( WIN_OLEAUTO___ONERROR ) pMemberArray = szMethodWide; lOleError = HB_VTBL( pDisp )->GetIDsOfNames( HB_THIS_( pDisp ) HB_ID_REF( IID_NULL ), &pMemberArray, 1, LOCALE_USER_DEFAULT, &dispid ); - hb_xfree( szMethodWide ); if( lOleError == S_OK ) { diff --git a/harbour/src/rtl/hbinet.c b/harbour/src/rtl/hbinet.c index a2b4cb6d50..8bf7f87334 100644 --- a/harbour/src/rtl/hbinet.c +++ b/harbour/src/rtl/hbinet.c @@ -1088,8 +1088,11 @@ HB_FUNC( HB_INETGETALIAS ) ****/ HB_FUNC( HB_INETIFINFO ) { - PHB_ITEM pInfo = hb_socketGetIFaces( hb_parnidef( 2, HB_SOCKET_PF_INET ), - hb_parl( 1 ) ); + PHB_ITEM pInfo; + + HB_INET_INITIALIZE(); + pInfo = hb_socketGetIFaces( hb_parnidef( 2, HB_SOCKET_PF_INET ), + hb_parl( 1 ) ); if( pInfo ) hb_itemReturnRelease( pInfo ); else diff --git a/harbour/src/vm/dynlibhb.c b/harbour/src/vm/dynlibhb.c index ce00b6cbf2..3c44081980 100644 --- a/harbour/src/vm/dynlibhb.c +++ b/harbour/src/vm/dynlibhb.c @@ -208,7 +208,7 @@ void * hb_libSymAddr( PHB_ITEM pDynLib, const char * pszSymbol ) return ( void * ) GetProcAddress( ( HMODULE ) hDynLib, pszSymbol ); #elif defined( HB_OS_OS2 ) PFN pProcAddr = NULL; - if( DosQueryProcAddr( ( HMODULE ) hDynLib, 0, pszSymbol, &pProcAddr ) == NO_ERROR ) + if( DosQueryProcAddr( ( HMODULE ) hDynLib, 0, ( PCSZ ) pszSymbol, &pProcAddr ) == NO_ERROR ) return ( void * ) pProcAddr; #elif defined( HB_HAS_DLFCN ) return dlsym( hDynLib, pszSymbol );