aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2022-06-25 15:26:04 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2022-06-27 12:13:20 +0200
commit1777fe6b3ce8359b49d133924f1488ce0b0cc628 (patch)
treea72d0fc2728d35736e3f1e58f31cb8ba094d59fe
parentb6b0d32a94a7ae21ac28be762be8ad50b092b177 (diff)
downloadsparse-1777fe6b3ce8359b49d133924f1488ce0b0cc628.tar.gz
inline: allocate statement after guards
In inline_function(), the statement that will correspond to the inlined code is allocated in the function declaration but then it's checked if the function can be allocated or not. This is not much memory and the checks should succeed most of the time but it's clearer if the statement is allocated after the checks. So, move the allocation after the checks. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--inline.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/inline.c b/inline.c
index a6f9252a..68f235c2 100644
--- a/inline.c
+++ b/inline.c
@@ -516,7 +516,7 @@ int inline_function(struct expression *expr, struct symbol *sym)
{
struct symbol_list * fn_symbol_list;
struct symbol *fn = sym->ctype.base_type;
- struct statement *stmt = alloc_statement(expr->pos, STMT_COMPOUND);
+ struct statement *stmt;
struct symbol_list *arg_decl;
struct symbol *name;
struct expression *arg;
@@ -528,6 +528,7 @@ int inline_function(struct expression *expr, struct symbol *sym)
if (fn->expanding)
return 0;
+ stmt = alloc_statement(expr->pos, STMT_COMPOUND);
expr->type = EXPR_STATEMENT;
expr->statement = stmt;
expr->ctype = fn->ctype.base_type;