From 2f67d778563abc187192c4e0a6e23a664495791e Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 12 Jan 2009 14:12:24 +0000 Subject: [PATCH] 2009-01-12 15:15 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/vm/fm.c * harbour/include/hbwmain.c * use HeapAlloc( GetProcessHeap(), ... ) instead of LocalAlloc() when HB_FM_WIN32_ALLOC macro is set - Toninho's tests show that it's a little bit more efficient - thanks. --- harbour/ChangeLog | 7 +++++++ harbour/include/hbwmain.c | 6 ++++-- harbour/source/vm/fm.c | 12 +++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f6e9a032dd..bbea83fb88 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,13 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-01-12 15:15 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/vm/fm.c + * harbour/include/hbwmain.c + * use HeapAlloc( GetProcessHeap(), ... ) instead of LocalAlloc() + when HB_FM_WIN32_ALLOC macro is set - Toninho's tests show that + it's a little bit more efficient - thanks. + 2009-01-09 17:59 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/hbct/ftoc.c * harbour/contrib/hbct/misc1.c diff --git a/harbour/include/hbwmain.c b/harbour/include/hbwmain.c index 08490cc1c8..2c67eac261 100644 --- a/harbour/include/hbwmain.c +++ b/harbour/include/hbwmain.c @@ -71,6 +71,7 @@ int WINAPI WinMain( HINSTANCE hInstance, /* handle to current instance */ LPSTR pArgs, pArg, pDst, pSrc, pFree; BOOL fQuoted; int iErrorCode; + HANDLE hHeap; /* HB_TRACE(HB_TR_DEBUG, ("WinMain(%p, %p, %s, %d)", hInstance, hPrevInstance, lpCmdLine, iCmdShow)); */ @@ -83,7 +84,8 @@ int WINAPI WinMain( HINSTANCE hInstance, /* handle to current instance */ #else pSrc = pFree = lpCmdLine; #endif - pDst = pArgs = ( LPSTR ) LocalAlloc( LMEM_FIXED, strlen( pFree ) + 1 ); + hHeap = GetProcessHeap(); + pDst = pArgs = ( LPSTR ) HeapAlloc( hHeap, 0, strlen( pFree ) + 1 ); fQuoted = FALSE; while( *pSrc != 0 && s_argc < HB_MAX_ARGS ) @@ -135,7 +137,7 @@ int WINAPI WinMain( HINSTANCE hInstance, /* handle to current instance */ iErrorCode = main( s_argc, s_argv ); #endif - LocalFree( pArgs ); + HeapFree( hHeap, 0, ( void * ) pArgs ); return iErrorCode; } diff --git a/harbour/source/vm/fm.c b/harbour/source/vm/fm.c index 5b6f231bfb..4d953cb02a 100644 --- a/harbour/source/vm/fm.c +++ b/harbour/source/vm/fm.c @@ -152,9 +152,15 @@ # define free( p ) dlfree( ( p ) ) # endif #elif defined( HB_FM_WIN32_ALLOC ) && defined( HB_OS_WIN_32 ) -# define malloc( n ) ( void * ) LocalAlloc( LMEM_FIXED, ( n ) ) -# define realloc( p, n ) ( void * ) LocalReAlloc( ( HLOCAL ) ( p ), ( n ), LMEM_MOVEABLE ) -# define free( p ) LocalFree( ( HLOCAL ) ( p ) ) +# if defined( HB_FM_LOCALALLOC ) +# define malloc( n ) ( void * ) LocalAlloc( LMEM_FIXED, ( n ) ) +# define realloc( p, n ) ( void * ) LocalReAlloc( ( HLOCAL ) ( p ), ( n ), LMEM_MOVEABLE ) +# define free( p ) LocalFree( ( HLOCAL ) ( p ) ) +# else +# define malloc( n ) ( void * ) HeapAlloc( GetProcessHeap(), 0, ( n ) ) +# define realloc( p, n ) ( void * ) HeapReAlloc( GetProcessHeap(), 0, ( void * ) ( p ), ( n ) ) +# define free( p ) HeapFree( GetProcessHeap(), 0, ( void * ) ( p ) ) +# endif #endif #if defined( HB_MT_VM ) && ( defined( HB_FM_STATISTICS ) || \