links, var_sym: allocate fewer states
commita73583631cc4d7de86945b0ee713d19c067b1bb3
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 15 May 2017 11:41:51 +0000 (15 14:41 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Mon, 15 May 2017 11:41:51 +0000 (15 14:41 +0300)
tree34fa4fb58d8578cf75f8f66b7e3e6760752a35cb
parent9d17aa54f45f20deb31ccff3f44195a243f20979
links, var_sym: allocate fewer states

When we merge link states we end up allocating new smatch_states when we
don't need to.

The link states a list of variables we need to modify.  When we merge them
then we just combine both lists.  If one list is empty, then we don't need
to allocate a new state, we can just re-use the state we already had.  If
the lists are the same then we again don't need to allocate a new state
but can just re-use one of the earlier states.

There was some infrastructure needed to make this work.  First store the
states in sorted order so it's easier to compare two of them.  Then add a
var_sym_lists_equiv() to see if they are the same.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch.h
smatch_links.c
smatch_var_sym.c