mirror of
https://github.com/boostorg/build.git
synced 2026-02-21 15:02:19 +00:00
Fix memory leaks in filesys.
This commit is contained in:
@@ -513,7 +513,7 @@ static void remove_files_atexit( void )
|
||||
|
||||
FILELIST * filelist_new( OBJECT * path )
|
||||
{
|
||||
FILELIST * list = (FILELIST *)BJAM_MALLOC( sizeof( FILELIST ) );
|
||||
FILELIST * list = b2::jam::make_ptr<FILELIST>();
|
||||
|
||||
memset( list, 0, sizeof( *list ) );
|
||||
list->size = 0;
|
||||
@@ -537,13 +537,10 @@ FILELIST * filelist_push_back( FILELIST * list, OBJECT * path )
|
||||
}
|
||||
|
||||
|
||||
item = (FILEITEM *)BJAM_MALLOC( sizeof( FILEITEM ) );
|
||||
memset( item, 0, sizeof( *item ) );
|
||||
item->value = (file_info_t *)BJAM_MALLOC( sizeof( file_info_t ) );
|
||||
item = b2::jam::make_ptr<FILEITEM>();
|
||||
item->value = b2::jam::make_ptr<file_info_t>();
|
||||
|
||||
file = item->value;
|
||||
memset( file, 0, sizeof( *file ) );
|
||||
|
||||
file->name = path;
|
||||
file->files = L0;
|
||||
|
||||
@@ -575,9 +572,9 @@ FILELIST * filelist_push_front( FILELIST * list, OBJECT * path )
|
||||
}
|
||||
|
||||
|
||||
item = (FILEITEM *)BJAM_MALLOC( sizeof( FILEITEM ) );
|
||||
item = b2::jam::make_ptr<FILEITEM>();
|
||||
memset( item, 0, sizeof( *item ) );
|
||||
item->value = (file_info_t *)BJAM_MALLOC( sizeof( file_info_t ) );
|
||||
item->value = b2::jam::make_ptr<file_info_t>();
|
||||
|
||||
file = item->value;
|
||||
memset( file, 0, sizeof( *file ) );
|
||||
@@ -610,15 +607,17 @@ FILELIST * filelist_pop_front( FILELIST * list )
|
||||
|
||||
if ( item )
|
||||
{
|
||||
if ( item->value ) free_file_info( item->value, 0 );
|
||||
if ( item->value )
|
||||
{
|
||||
free_file_info( item->value, 0 );
|
||||
b2::jam::free_ptr( item->value );
|
||||
}
|
||||
|
||||
list->head = item->next;
|
||||
list->size--;
|
||||
if ( !list->size ) list->tail = list->head;
|
||||
|
||||
#ifdef BJAM_NO_MEM_CACHE
|
||||
BJAM_FREE( item );
|
||||
#endif
|
||||
b2::jam::free_ptr( item );
|
||||
}
|
||||
|
||||
return list;
|
||||
@@ -638,9 +637,7 @@ void filelist_free( FILELIST * list )
|
||||
|
||||
while ( filelist_length( list ) ) filelist_pop_front( list );
|
||||
|
||||
#ifdef BJAM_NO_MEM_CACHE
|
||||
BJAM_FREE( list );
|
||||
#endif
|
||||
b2::jam::free_ptr( list );
|
||||
}
|
||||
|
||||
int filelist_empty( FILELIST * list )
|
||||
|
||||
Reference in New Issue
Block a user