2009-10-30 03:40 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/src/common/hbgete.c
  * harbour/src/common/hbffind.c
  * harbour/src/common/hbfsapi.c
  * harbour/src/rtl/fstemp.c
  * harbour/src/rtl/filesys.c
  * harbour/src/rtl/diskspac.c
  * harbour/src/rtl/disksphb.c
  * harbour/src/rtl/net.c
    ! fixed memory leak reported by Pritpal
    * cleanup some UNICODE conversions in Windows builds (mostly resolved
      some macros when UNICODE macro is also explicitly used and cleaned
      some buffers length passed to windows functions.
    * removed unnecessary casting - if it's not necessary for some strange
      reasons never cast strings to LP[C][TW]STR calling windows functions.
      Such casting does not make any conversions but only hides potential
      bugs.

  * harbour/contrib/hbwin/axcore.c
    * pacified warning
This commit is contained in:
Przemyslaw Czerpak
2009-10-30 02:41:17 +00:00
parent 8148d544e5
commit f7f2caa607
10 changed files with 57 additions and 36 deletions

View File

@@ -17,6 +17,27 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-10-30 03:40 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/src/common/hbgete.c
* harbour/src/common/hbffind.c
* harbour/src/common/hbfsapi.c
* harbour/src/rtl/fstemp.c
* harbour/src/rtl/filesys.c
* harbour/src/rtl/diskspac.c
* harbour/src/rtl/disksphb.c
* harbour/src/rtl/net.c
! fixed memory leak reported by Pritpal
* cleanup some UNICODE conversions in Windows builds (mostly resolved
some macros when UNICODE macro is also explicitly used and cleaned
some buffers length passed to windows functions.
* removed unnecessary casting - if it's not necessary for some strange
reasons never cast strings to LP[C][TW]STR calling windows functions.
Such casting does not make any conversions but only hides potential
bugs.
* harbour/contrib/hbwin/axcore.c
* pacified warning
2009-10-29 22:30 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/doc/xhb-diff.txt
+ added information about Harbour and xHarbour versions described by

View File

@@ -343,7 +343,7 @@ static HRESULT STDMETHODCALLTYPE Invoke( IDispatch* lpThis, DISPID dispid, REFII
iCount = pParams->cArgs;
for( i = iRefs = 0; i < iCount && iRefs < HB_SIZEOFARRAY( refArray ); i++ )
for( i = iRefs = 0; i < iCount && iRefs < ( int ) HB_SIZEOFARRAY( refArray ); i++ )
{
if( pParams->rgvarg[ i ].n1.n2.vt & VT_BYREF )
refArray[ iRefs++ ].item = hb_stackAllocItem();

View File

@@ -533,10 +533,10 @@ static BOOL hb_fsFindNextLow( PHB_FFIND ffind )
ffind->bFirst = FALSE;
ffind->szName[ 0 ] = '\0';
bFound = GetVolumeInformation( ( LPCTSTR ) lpFileMask, szName, sizeof( szName ) - 1, NULL, NULL, NULL, NULL, 0 );
bFound = GetVolumeInformation( lpFileMask, szName, sizeof( szName ) - 1, NULL, NULL, NULL, NULL, 0 );
HB_TCHAR_FREE( lpFileMask );
HB_TCHAR_GETFROM( ffind->szName, szName, sizeof( ffind->szName ) - 1 );
HB_TCHAR_GETFROM( ffind->szName, szName, sizeof( ffind->szName ) );
}
#endif
}
@@ -548,7 +548,7 @@ static BOOL hb_fsFindNextLow( PHB_FFIND ffind )
ffind->bFirst = FALSE;
info->hFindFile = FindFirstFile( ( LPCTSTR ) lpFileMask, &info->pFindFileData );
info->hFindFile = FindFirstFile( lpFileMask, &info->pFindFileData );
info->dwAttr = ( DWORD ) hb_fsAttrToRaw( ffind->attrmask );
if( ( info->hFindFile != INVALID_HANDLE_VALUE ) && HB_WIN_MATCH() )

View File

@@ -312,7 +312,7 @@ BOOL hb_fsNameExists( const char * pszFileName )
{
LPTSTR lpFileName = HB_TCHAR_CONVTO( pszFileName );
fExist = ( GetFileAttributes( ( LPCTSTR ) lpFileName ) != INVALID_FILE_ATTRIBUTES );
fExist = ( GetFileAttributes( lpFileName ) != INVALID_FILE_ATTRIBUTES );
HB_TCHAR_FREE( lpFileName );
}
@@ -370,7 +370,7 @@ BOOL hb_fsFileExists( const char * pszFileName )
LPTSTR lpFileName = HB_TCHAR_CONVTO( pszFileName );
DWORD dwAttr;
dwAttr = GetFileAttributes( ( LPCTSTR ) lpFileName );
dwAttr = GetFileAttributes( lpFileName );
fExist = ( dwAttr != INVALID_FILE_ATTRIBUTES ) &&
( dwAttr & ( FILE_ATTRIBUTE_DIRECTORY |
FILE_ATTRIBUTE_DEVICE ) ) == 0;
@@ -433,7 +433,7 @@ BOOL hb_fsDirExists( const char * pszDirName )
LPTSTR lpDirName = HB_TCHAR_CONVTO( pszDirName );
DWORD dwAttr;
dwAttr = GetFileAttributes( ( LPCTSTR ) lpDirName );
dwAttr = GetFileAttributes( lpDirName );
fExist = ( dwAttr != INVALID_FILE_ATTRIBUTES ) &&
( dwAttr & FILE_ATTRIBUTE_DIRECTORY );

View File

@@ -79,12 +79,13 @@ char * hb_getenv( const char * szName )
{
LPTSTR lpBuffer = ( LPTSTR ) hb_xgrab( size * sizeof( TCHAR ) );
GetEnvironmentVariable( lpName, lpBuffer, size );
pszBuffer = HB_TCHAR_CONVFROM( lpBuffer );
#if defined( UNICODE )
HB_TCHAR_FREE( lpBuffer );
pszBuffer = hb_wctomb( lpBuffer );
hb_xfree( lpBuffer );
#else
pszBuffer = lpBuffer;
#endif
}
HB_TCHAR_FREE( lpName );
}
@@ -146,7 +147,7 @@ BOOL hb_getenv_buffer( const char * szName, char * szBuffer, int nSize )
if( lpBuffer && lpBuffer != buffer )
hb_xfree( lpBuffer );
#else
fRetVal = GetEnvironmentVariableA( szName, szBuffer, nSize ) != 0;
fRetVal = GetEnvironmentVariable( szName, szBuffer, nSize ) != 0;
#endif
}
#elif defined( HB_OS_OS2 )

View File

@@ -125,7 +125,7 @@ HB_FUNC( DISKSPACE )
#if defined( HB_OS_WIN_CE )
TCHAR lpPath[ 4 ];
lpPath[ 0 ] = ( TCHAR ) uiDrive + 'A' - 1;
lpPath[ 0 ] = ( TCHAR ) ( uiDrive + 'A' - 1 );
lpPath[ 1 ] = ':';
lpPath[ 2 ] = '\\';
lpPath[ 3 ] = '\0';
@@ -164,7 +164,7 @@ HB_FUNC( DISKSPACE )
DWORD dwNumberOfFreeClusters;
DWORD dwTotalNumberOfClusters;
bError = ! GetDiskFreeSpace( ( LPCTSTR ) lpPath,
bError = ! GetDiskFreeSpace( lpPath,
&dwSectorsPerCluster,
&dwBytesPerSector,
&dwNumberOfFreeClusters,

View File

@@ -249,12 +249,13 @@ HB_FUNC( HB_DISKSPACE )
DWORD dwNumberOfFreeClusters;
DWORD dwTotalNumberOfClusters;
fResult = GetDiskFreeSpace( ( LPCTSTR ) lpPath,
fResult = GetDiskFreeSpace( lpPath,
&dwSectorsPerCluster,
&dwBytesPerSector,
&dwNumberOfFreeClusters,
&dwTotalNumberOfClusters );
hb_fsSetIOError( fResult, 0 );
HB_TCHAR_FREE( lpPath );
if( fResult )
{
switch( uiType )
@@ -279,8 +280,6 @@ HB_FUNC( HB_DISKSPACE )
break;
}
}
HB_TCHAR_FREE( lpPath );
}
#endif
SetErrorMode( uiErrMode );

View File

@@ -661,7 +661,7 @@ HB_FHANDLE hb_fsOpen( const char * pFilename, USHORT uiFlags )
convert_open_flags( FALSE, FC_NORMAL, uiFlags, &dwMode, &dwShare, &dwCreat, &dwAttr );
hb_vmUnlock();
hFile = CreateFile( ( LPCTSTR ) lpFilename, dwMode, dwShare, NULL, dwCreat, dwAttr, NULL );
hFile = CreateFile( lpFilename, dwMode, dwShare, NULL, dwCreat, dwAttr, NULL );
hb_fsSetIOError( hFile != ( HANDLE ) INVALID_HANDLE_VALUE, 0 );
hb_vmLock();
@@ -723,7 +723,7 @@ HB_FHANDLE hb_fsCreate( const char * pFilename, ULONG ulAttr )
convert_open_flags( TRUE, ulAttr, FO_EXCLUSIVE, &dwMode, &dwShare, &dwCreat, &dwAttr );
hb_vmUnlock();
hFile = CreateFile( ( LPCTSTR ) lpFilename, dwMode, dwShare, NULL, dwCreat, dwAttr, NULL );
hFile = CreateFile( lpFilename, dwMode, dwShare, NULL, dwCreat, dwAttr, NULL );
hb_fsSetIOError( hFile != ( HANDLE ) INVALID_HANDLE_VALUE, 0 );
hb_vmLock();
@@ -785,7 +785,7 @@ HB_FHANDLE hb_fsCreateEx( const char * pFilename, ULONG ulAttr, USHORT uiFlags )
convert_open_flags( TRUE, ulAttr, uiFlags, &dwMode, &dwShare, &dwCreat, &dwAttr );
hb_vmUnlock();
hFile = CreateFile( ( LPCTSTR ) lpFilename, dwMode, dwShare, NULL, dwCreat, dwAttr, NULL );
hFile = CreateFile( lpFilename, dwMode, dwShare, NULL, dwCreat, dwAttr, NULL );
hb_fsSetIOError( hFile != ( HANDLE ) INVALID_HANDLE_VALUE, 0 );
hb_vmLock();

View File

@@ -150,17 +150,15 @@ static HB_FHANDLE hb_fsCreateTempLow( const char * pszDir, const char * pszPrefi
else
{
#if defined( HB_OS_WIN )
LPTSTR lpName = ( LPTSTR ) hb_xgrab( HB_PATH_MAX * sizeof( TCHAR ) );
TCHAR lpName[ HB_PATH_MAX ];
if( GetTempPath( ( DWORD ) ( HB_PATH_MAX - 1 ), lpName ) )
if( GetTempPath( HB_PATH_MAX, lpName ) )
HB_TCHAR_GETFROM( pszName, lpName, HB_PATH_MAX );
else
{
pszName[ 0 ] = '.';
pszName[ 1 ] = '\0';
}
HB_TCHAR_FREE( lpName );
#else
char * pszTmpDir = hb_getenv( "TMPDIR" );
@@ -268,25 +266,25 @@ static BOOL hb_fsTempName( char * pszBuffer, const char * pszDir, const char * p
#if defined( HB_IO_WIN )
{
LPTSTR lpPrefix = pszPrefix ? HB_TCHAR_CONVTO( pszPrefix ) : NULL;
LPTSTR lpBuffer = ( LPTSTR ) hb_xgrab( HB_PATH_MAX * sizeof( TCHAR ) );
TCHAR pTempDir[ HB_PATH_MAX ];
TCHAR lpBuffer[ HB_PATH_MAX ];
TCHAR lpTempDir[ HB_PATH_MAX ];
if( pszDir && pszDir[ 0 ] != '\0' )
HB_TCHAR_SETTO( pTempDir, pszDir, HB_SIZEOFARRAY( pTempDir ) - 1 );
HB_TCHAR_SETTO( lpTempDir, pszDir, HB_PATH_MAX );
else
{
if( ! GetTempPath( ( DWORD ) HB_SIZEOFARRAY( pTempDir ) - 1, pTempDir ) )
if( ! GetTempPath( HB_PATH_MAX, lpTempDir ) )
{
hb_fsSetIOError( FALSE, 0 );
return FALSE;
}
}
pTempDir[ HB_PATH_MAX - 1 ] = L'\0';
lpTempDir[ HB_PATH_MAX - 1 ] = L'\0';
fResult = GetTempFileName( pTempDir, lpPrefix ? lpPrefix : TEXT( "hb" ), 0, lpBuffer );
fResult = GetTempFileName( lpTempDir, lpPrefix ? lpPrefix : TEXT( "hb" ), 0, lpBuffer );
HB_TCHAR_GETFROM( pszBuffer, lpBuffer, HB_PATH_MAX );
HB_TCHAR_FREE( lpBuffer );
if( lpPrefix )
HB_TCHAR_FREE( lpPrefix );
}

View File

@@ -151,15 +151,16 @@ char * hb_netname( void )
#elif defined( HB_OS_WIN )
DWORD ulLen = MAX_COMPUTERNAME_LENGTH + 1;
LPTSTR lpValue = ( LPTSTR ) hb_xgrab( ulLen * sizeof( TCHAR ) );
TCHAR lpValue[ MAX_COMPUTERNAME_LENGTH + 1 ];
char * pszValue;
lpValue[ 0 ] = L'\0';
GetComputerName( lpValue, &ulLen );
pszValue = HB_TCHAR_CONVFROM( lpValue );
#if defined( UNICODE )
HB_TCHAR_FREE( lpValue );
pszValue = hb_wctomb( lpValue );
#else
pszValue = hb_strdup( lpValue );
#endif
return pszValue;
@@ -187,15 +188,16 @@ char * hb_username( void )
#elif defined( HB_OS_WIN )
DWORD ulLen = 256;
LPTSTR lpValue = ( LPTSTR ) hb_xgrab( ulLen * sizeof( TCHAR ) );
TCHAR lpValue[ 256 ];
char * pszValue;
lpValue[ 0 ] = L'\0';
GetUserName( lpValue, &ulLen );
pszValue = HB_TCHAR_CONVFROM( lpValue );
#if defined( UNICODE )
HB_TCHAR_FREE( lpValue );
pszValue = hb_wctomb( lpValue );
#else
pszValue = hb_strdup( lpValue );
#endif
return pszValue;