2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-21 15:02:19 +00:00

Convert alloc/free calls with unique_ptr managed code.

Using unique_ptr allows to not loose track of memory when early
exit when clean_exit throws an exception.
This commit is contained in:
Rene Rivera
2022-03-03 21:39:00 -06:00
parent a9aafc7a70
commit a9aed5c40a
2 changed files with 5 additions and 8 deletions

View File

@@ -145,10 +145,8 @@ LIST * evaluate_rule( RULE * rule, OBJECT * rulename, FRAME * frame )
*/
if ( rule->procedure )
{
FUNCTION * const function = rule->procedure;
function_refer( function );
result = function_run( function, frame, stack_global() );
function_free( function );
auto function = b2::jam::make_unique_bare_jptr( rule->procedure, function_refer, function_free );
result = function_run( function.get(), frame, stack_global() );
}
if ( DEBUG_PROFILE && rule->procedure )

View File

@@ -18,6 +18,7 @@
#include "modules.h"
#include "frames.h"
#include "function.h"
#include "mem.h"
/*
* parse.c - make and destroy parse trees as driven by the parser
@@ -40,7 +41,6 @@ static void parse_impl( FRAME * frame )
for ( ; ; )
{
PARSE * p;
FUNCTION * func;
/* Filled by yyparse() calling parse_save(). */
yypsave = 0;
@@ -50,10 +50,9 @@ static void parse_impl( FRAME * frame )
break;
/* Run the parse tree. */
func = function_compile( p );
auto func = b2::jam::make_unique_bare_jptr( function_compile( p ), function_free );
parse_free( p );
list_free( function_run( func, frame, stack_global() ) );
function_free( func );
list_free( function_run( func.get(), frame, stack_global() ) );
}
yyfdone();