mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 01:07:52 +00:00
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.
This commit is contained in:
@@ -1095,13 +1095,9 @@ struct rank
|
||||
short subrank;
|
||||
};
|
||||
|
||||
/* * Struct used for ranking a function for overload resolution. */
|
||||
/* * Used for ranking a function for overload resolution. */
|
||||
|
||||
struct badness_vector
|
||||
{
|
||||
int length;
|
||||
struct rank *rank;
|
||||
};
|
||||
typedef std::vector<rank> badness_vector;
|
||||
|
||||
/* * GNAT Ada-specific information for various Ada types. */
|
||||
|
||||
@@ -1983,8 +1979,6 @@ extern int is_unique_ancestor (struct type *, struct value *);
|
||||
|
||||
/* Overload resolution */
|
||||
|
||||
#define LENGTH_MATCH(bv) ((bv)->rank[0])
|
||||
|
||||
/* * Badness if parameter list length doesn't match arg list length. */
|
||||
extern const struct rank LENGTH_MISMATCH_BADNESS;
|
||||
|
||||
@@ -2043,10 +2037,11 @@ extern const struct rank NS_INTEGER_POINTER_CONVERSION_BADNESS;
|
||||
extern struct rank sum_ranks (struct rank a, struct rank b);
|
||||
extern int compare_ranks (struct rank a, struct rank b);
|
||||
|
||||
extern int compare_badness (struct badness_vector *, struct badness_vector *);
|
||||
extern int compare_badness (const badness_vector &,
|
||||
const badness_vector &);
|
||||
|
||||
extern struct badness_vector *rank_function (gdb::array_view<type *> parms,
|
||||
gdb::array_view<value *> args);
|
||||
extern badness_vector rank_function (gdb::array_view<type *> parms,
|
||||
gdb::array_view<value *> args);
|
||||
|
||||
extern struct rank rank_one_type (struct type *, struct type *,
|
||||
struct value *);
|
||||
|
||||
Reference in New Issue
Block a user