C++ify badness_vector, fix leaks
authorPedro Alves <palves@redhat.com>
Wed, 21 Nov 2018 11:55:14 +0000 (11:55 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 21 Nov 2018 12:06:51 +0000 (12:06 +0000)
commit82ceee50146563a61ed19f4ad585d39636a6dfa8
treed9d048333a3fe7357d97a79ed4b6cb0f93a9b053
parent0891c3cc132495ad7b323896efae4f91eca87c6c
C++ify badness_vector, fix leaks

badness_vector is currently an open coded vector.  This reimplements
it as a std::vector.

This fixes a few leaks as well:

 - find_oload_champ is leaking every badness vector calculated bar the
   one returned.

 - bv->rank is always leaked, since callers of rank_function only
   xfree the badness_vector pointer, not bv->rank.

gdb/ChangeLog:
2018-11-21  Pedro Alves  <palves@redhat.com>

* gdbtypes.c (compare_badness): Change type of parameters to const
reference.  Adjust to badness_vector being a std::vector now.
(rank_function): Adjust to badness_vector being a std::vector now.
* gdbtypes.h (badness_vector): Now a typedef to std::vector.
(LENGTH_MATCH): Delete.
(compare_badness): Change type of parameters to const reference.
(rank_function): Return a badness_vector by value now.
(find_overload_match): Adjust to badness_vector being a
std::vector now.  Remove cleanups.
(find_oload_champ_namespace): 'oload_champ_bv' parameter now a
badness_vector pointer.
(find_oload_champ_namespace_loop): 'oload_champ_bv' parameter now
a badness_vector pointer.  Adjust to badness_vector being a
std::vector now.  Remove cleanups.
(find_oload_champ): 'oload_champ_bv' parameter now
a badness_vector pointer.  Adjust to badness_vector being a
std::vector now.  Remove cleanups.
gdb/ChangeLog
gdb/gdbtypes.c
gdb/gdbtypes.h
gdb/valops.c