Skip to content

Commit fcddf19

Browse files
alexhenriejulliard
authored andcommitted
cabarc: Use CRT allocation functions.
1 parent 240e438 commit fcddf19

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

programs/cabarc/cabarc.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ static WCHAR **opt_files;
4747

4848
static void * CDECL cab_alloc( ULONG size )
4949
{
50-
return HeapAlloc( GetProcessHeap(), 0, size );
50+
return malloc( size );
5151
}
5252

5353
static void CDECL cab_free( void *ptr )
5454
{
55-
HeapFree( GetProcessHeap(), 0, ptr );
55+
free( ptr );
5656
}
5757

5858
static WCHAR *strdupAtoW( UINT cp, const char *str )
@@ -61,7 +61,7 @@ static WCHAR *strdupAtoW( UINT cp, const char *str )
6161
if (str)
6262
{
6363
DWORD len = MultiByteToWideChar( cp, 0, str, -1, NULL, 0 );
64-
if ((ret = cab_alloc( len * sizeof(WCHAR) )))
64+
if ((ret = malloc( len * sizeof(WCHAR) )))
6565
MultiByteToWideChar( cp, 0, str, -1, ret, len );
6666
}
6767
return ret;
@@ -73,7 +73,7 @@ static char *strdupWtoA( UINT cp, const WCHAR *str )
7373
if (str)
7474
{
7575
DWORD len = WideCharToMultiByte( cp, 0, str, -1, NULL, 0, NULL, NULL );
76-
if ((ret = cab_alloc( len )))
76+
if ((ret = malloc( len )))
7777
WideCharToMultiByte( cp, 0, str, -1, ret, len, NULL, NULL );
7878
}
7979
return ret;
@@ -236,21 +236,21 @@ static INT_PTR CDECL fci_get_open_info( char *name, USHORT *date, USHORT *time,
236236
{
237237
*err = GetLastError();
238238
WINE_ERR( "failed to open %s: error %u\n", wine_dbgstr_w(nameW), *err );
239-
cab_free( nameW );
239+
free( nameW );
240240
return -1;
241241
}
242242
if (!GetFileInformationByHandle( handle, &info ))
243243
{
244244
*err = GetLastError();
245245
CloseHandle( handle );
246-
cab_free( nameW );
246+
free( nameW );
247247
return -1;
248248
}
249249
FileTimeToDosDateTime( &info.ftLastWriteTime, date, time );
250250
*attribs = info.dwFileAttributes & (_A_RDONLY | _A_HIDDEN | _A_SYSTEM | _A_ARCH);
251251
for (p = nameW; *p; p++) if (*p >= 0x80) break;
252252
if (*p) *attribs |= _A_NAME_IS_UTF;
253-
cab_free( nameW );
253+
free( nameW );
254254
return (INT_PTR)handle;
255255
}
256256

@@ -291,8 +291,7 @@ static void create_directories( const WCHAR *name )
291291
WCHAR *path, *p;
292292

293293
/* create the directory/directories */
294-
path = cab_alloc( (lstrlenW(name) + 1) * sizeof(WCHAR) );
295-
lstrcpyW(path, name);
294+
path = wcsdup( name );
296295

297296
p = wcschr(path, '\\');
298297
while (p != NULL)
@@ -303,7 +302,7 @@ static void create_directories( const WCHAR *name )
303302
*p = '\\';
304303
p = wcschr(p+1, '\\');
305304
}
306-
cab_free( path );
305+
free( path );
307306
}
308307

309308
/* 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
349348
}
350349
wprintf( L"%s\n", nameW );
351350
}
352-
cab_free( nameW );
351+
free( nameW );
353352
return 0;
354353
default:
355354
WINE_FIXME( "Unexpected notification type %d.\n", fdint );
@@ -394,7 +393,7 @@ static INT_PTR CDECL extract_notify( FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION
394393

395394
if (opt_dest_dir)
396395
{
397-
path = cab_alloc( (lstrlenW(opt_dest_dir) + lstrlenW(file) + 1) * sizeof(WCHAR) );
396+
path = malloc( (wcslen(opt_dest_dir) + wcslen(file) + 1) * sizeof(WCHAR) );
398397
lstrcpyW( path, opt_dest_dir );
399398
lstrcatW( path, file );
400399
}
@@ -410,8 +409,8 @@ static INT_PTR CDECL extract_notify( FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION
410409
}
411410
else ret = 0;
412411

413-
cab_free( nameW );
414-
if (path != file) cab_free( path );
412+
free( nameW );
413+
if (path != file) free( path );
415414
return ret;
416415

417416
case fdintCLOSE_FILE_INFO:
@@ -464,7 +463,7 @@ static BOOL add_file( HFCI fci, WCHAR *name )
464463
}
465464
ret = FCIAddFile( fci, path, filename, FALSE,
466465
fci_get_next_cab, fci_status, fci_get_open_info, opt_compression );
467-
cab_free( path );
466+
free( path );
468467
return ret;
469468
}
470469

@@ -475,7 +474,7 @@ static BOOL add_directory( HFCI fci, WCHAR *dir )
475474
WIN32_FIND_DATAW data;
476475
BOOL ret = TRUE;
477476

478-
if (!(buffer = cab_alloc( (lstrlenW(dir) + MAX_PATH + 2) * sizeof(WCHAR) ))) return FALSE;
477+
if (!(buffer = malloc( (wcslen(dir) + MAX_PATH + 2) * sizeof(WCHAR) ))) return FALSE;
479478
lstrcpyW( buffer, dir );
480479
p = buffer + lstrlenW( buffer );
481480
if (p > buffer && p[-1] != '\\') *p++ = '\\';
@@ -498,7 +497,7 @@ static BOOL add_directory( HFCI fci, WCHAR *dir )
498497
} while (FindNextFileW( handle, &data ));
499498
FindClose( handle );
500499
}
501-
cab_free( buffer );
500+
free( buffer );
502501
return TRUE;
503502
}
504503

0 commit comments

Comments
 (0)