From 3c8442e46cb578e9efe3d07c387cbe65d968a038 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 23 Mar 2018 16:49:35 +0300 Subject: [PATCH] math: allocated some permanent range lists in rl_zero() and rl_one() Now that range lists are freed better, we can use permanent range lists here. It makes no difference in real life, but it felt good. Signed-off-by: Dan Carpenter --- smatch_math.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/smatch_math.c b/smatch_math.c index d12faf0f..51308639 100644 --- a/smatch_math.c +++ b/smatch_math.c @@ -32,12 +32,21 @@ static sval_t one = {.type = &int_ctype, {.value = 1} }; struct range_list *rl_zero(void) { - return alloc_rl(zero, zero); + static struct range_list *zero_perm; + + if (!zero_perm) + zero_perm = clone_rl_permanent(alloc_rl(zero, zero)); + return zero_perm; } struct range_list *rl_one(void) { - return alloc_rl(one, one); + static struct range_list *one_perm; + + if (!one_perm) + one_perm = clone_rl_permanent(alloc_rl(one, one)); + + return one_perm; } enum { -- 2.11.4.GIT