Commit fcddf194 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

cabarc: Use CRT allocation functions.

parent 240e4387
...@@ -47,12 +47,12 @@ static WCHAR **opt_files; ...@@ -47,12 +47,12 @@ static WCHAR **opt_files;
static void * CDECL cab_alloc( ULONG size ) static void * CDECL cab_alloc( ULONG size )
{ {
return HeapAlloc( GetProcessHeap(), 0, size ); return malloc( size );
} }
static void CDECL cab_free( void *ptr ) static void CDECL cab_free( void *ptr )
{ {
HeapFree( GetProcessHeap(), 0, ptr ); free( ptr );
} }
static WCHAR *strdupAtoW( UINT cp, const char *str ) static WCHAR *strdupAtoW( UINT cp, const char *str )
...@@ -61,7 +61,7 @@ static WCHAR *strdupAtoW( UINT cp, const char *str ) ...@@ -61,7 +61,7 @@ static WCHAR *strdupAtoW( UINT cp, const char *str )
if (str) if (str)
{ {
DWORD len = MultiByteToWideChar( cp, 0, str, -1, NULL, 0 ); DWORD len = MultiByteToWideChar( cp, 0, str, -1, NULL, 0 );
if ((ret = cab_alloc( len * sizeof(WCHAR) ))) if ((ret = malloc( len * sizeof(WCHAR) )))
MultiByteToWideChar( cp, 0, str, -1, ret, len ); MultiByteToWideChar( cp, 0, str, -1, ret, len );
} }
return ret; return ret;
...@@ -73,7 +73,7 @@ static char *strdupWtoA( UINT cp, const WCHAR *str ) ...@@ -73,7 +73,7 @@ static char *strdupWtoA( UINT cp, const WCHAR *str )
if (str) if (str)
{ {
DWORD len = WideCharToMultiByte( cp, 0, str, -1, NULL, 0, NULL, NULL ); DWORD len = WideCharToMultiByte( cp, 0, str, -1, NULL, 0, NULL, NULL );
if ((ret = cab_alloc( len ))) if ((ret = malloc( len )))
WideCharToMultiByte( cp, 0, str, -1, ret, len, NULL, NULL ); WideCharToMultiByte( cp, 0, str, -1, ret, len, NULL, NULL );
} }
return ret; return ret;
...@@ -236,21 +236,21 @@ static INT_PTR CDECL fci_get_open_info( char *name, USHORT *date, USHORT *time, ...@@ -236,21 +236,21 @@ static INT_PTR CDECL fci_get_open_info( char *name, USHORT *date, USHORT *time,
{ {
*err = GetLastError(); *err = GetLastError();
WINE_ERR( "failed to open %s: error %u\n", wine_dbgstr_w(nameW), *err ); WINE_ERR( "failed to open %s: error %u\n", wine_dbgstr_w(nameW), *err );
cab_free( nameW ); free( nameW );
return -1; return -1;
} }
if (!GetFileInformationByHandle( handle, &info )) if (!GetFileInformationByHandle( handle, &info ))
{ {
*err = GetLastError(); *err = GetLastError();
CloseHandle( handle ); CloseHandle( handle );
cab_free( nameW ); free( nameW );
return -1; return -1;
} }
FileTimeToDosDateTime( &info.ftLastWriteTime, date, time ); FileTimeToDosDateTime( &info.ftLastWriteTime, date, time );
*attribs = info.dwFileAttributes & (_A_RDONLY | _A_HIDDEN | _A_SYSTEM | _A_ARCH); *attribs = info.dwFileAttributes & (_A_RDONLY | _A_HIDDEN | _A_SYSTEM | _A_ARCH);
for (p = nameW; *p; p++) if (*p >= 0x80) break; for (p = nameW; *p; p++) if (*p >= 0x80) break;
if (*p) *attribs |= _A_NAME_IS_UTF; if (*p) *attribs |= _A_NAME_IS_UTF;
cab_free( nameW ); free( nameW );
return (INT_PTR)handle; return (INT_PTR)handle;
} }
...@@ -291,8 +291,7 @@ static void create_directories( const WCHAR *name ) ...@@ -291,8 +291,7 @@ static void create_directories( const WCHAR *name )
WCHAR *path, *p; WCHAR *path, *p;
/* create the directory/directories */ /* create the directory/directories */
path = cab_alloc( (lstrlenW(name) + 1) * sizeof(WCHAR) ); path = wcsdup( name );
lstrcpyW(path, name);
p = wcschr(path, '\\'); p = wcschr(path, '\\');
while (p != NULL) while (p != NULL)
...@@ -303,7 +302,7 @@ static void create_directories( const WCHAR *name ) ...@@ -303,7 +302,7 @@ static void create_directories( const WCHAR *name )
*p = '\\'; *p = '\\';
p = wcschr(p+1, '\\'); p = wcschr(p+1, '\\');
} }
cab_free( path ); free( path );
} }
/* check if file name matches against one of the files specification */ /* check if file name matches against one of the files specification */
...@@ -349,7 +348,7 @@ static INT_PTR CDECL list_notify( FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pf ...@@ -349,7 +348,7 @@ static INT_PTR CDECL list_notify( FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pf
} }
wprintf( L"%s\n", nameW ); wprintf( L"%s\n", nameW );
} }
cab_free( nameW ); free( nameW );
return 0; return 0;
default: default:
WINE_FIXME( "Unexpected notification type %d.\n", fdint ); WINE_FIXME( "Unexpected notification type %d.\n", fdint );
...@@ -394,7 +393,7 @@ static INT_PTR CDECL extract_notify( FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION ...@@ -394,7 +393,7 @@ static INT_PTR CDECL extract_notify( FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION
if (opt_dest_dir) if (opt_dest_dir)
{ {
path = cab_alloc( (lstrlenW(opt_dest_dir) + lstrlenW(file) + 1) * sizeof(WCHAR) ); path = malloc( (wcslen(opt_dest_dir) + wcslen(file) + 1) * sizeof(WCHAR) );
lstrcpyW( path, opt_dest_dir ); lstrcpyW( path, opt_dest_dir );
lstrcatW( path, file ); lstrcatW( path, file );
} }
...@@ -410,8 +409,8 @@ static INT_PTR CDECL extract_notify( FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION ...@@ -410,8 +409,8 @@ static INT_PTR CDECL extract_notify( FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION
} }
else ret = 0; else ret = 0;
cab_free( nameW ); free( nameW );
if (path != file) cab_free( path ); if (path != file) free( path );
return ret; return ret;
case fdintCLOSE_FILE_INFO: case fdintCLOSE_FILE_INFO:
...@@ -464,7 +463,7 @@ static BOOL add_file( HFCI fci, WCHAR *name ) ...@@ -464,7 +463,7 @@ static BOOL add_file( HFCI fci, WCHAR *name )
} }
ret = FCIAddFile( fci, path, filename, FALSE, ret = FCIAddFile( fci, path, filename, FALSE,
fci_get_next_cab, fci_status, fci_get_open_info, opt_compression ); fci_get_next_cab, fci_status, fci_get_open_info, opt_compression );
cab_free( path ); free( path );
return ret; return ret;
} }
...@@ -475,7 +474,7 @@ static BOOL add_directory( HFCI fci, WCHAR *dir ) ...@@ -475,7 +474,7 @@ static BOOL add_directory( HFCI fci, WCHAR *dir )
WIN32_FIND_DATAW data; WIN32_FIND_DATAW data;
BOOL ret = TRUE; BOOL ret = TRUE;
if (!(buffer = cab_alloc( (lstrlenW(dir) + MAX_PATH + 2) * sizeof(WCHAR) ))) return FALSE; if (!(buffer = malloc( (wcslen(dir) + MAX_PATH + 2) * sizeof(WCHAR) ))) return FALSE;
lstrcpyW( buffer, dir ); lstrcpyW( buffer, dir );
p = buffer + lstrlenW( buffer ); p = buffer + lstrlenW( buffer );
if (p > buffer && p[-1] != '\\') *p++ = '\\'; if (p > buffer && p[-1] != '\\') *p++ = '\\';
...@@ -498,7 +497,7 @@ static BOOL add_directory( HFCI fci, WCHAR *dir ) ...@@ -498,7 +497,7 @@ static BOOL add_directory( HFCI fci, WCHAR *dir )
} while (FindNextFileW( handle, &data )); } while (FindNextFileW( handle, &data ));
FindClose( handle ); FindClose( handle );
} }
cab_free( buffer ); free( buffer );
return TRUE; return TRUE;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment