Convert target_structs vector to VEC
I thought that this home made implementation of a vector could be replaced by the more standard VEC. The implementation seems to predate the introduction of vec.h, so that would explain why it exists. Ran make check before and after, no new failures. gdb/ChangeLog: 2014-08-19 Simon Marchi <simon.marchi@ericsson.com> * target.c (target_struct_size): Remove. (target_struct_allocsize): Remove. (DEFAULT_ALLOCSIZE): Remove. (target_ops_p): New typedef. (DEF_VEC_P (target_ops_p)): New vector type. (target_structs): Change type to VEC (target_ops_p). (add_target_with_completer): Replace "push" code by VEC_safe_push. (find_default_run_target): Rewrite for loop following changes to target_structs.
This commit is contained in:
parent
f7f2534e71
commit
89a1c21a1d
|
@ -1,3 +1,15 @@
|
||||||
|
2014-08-19 Simon Marchi <simon.marchi@ericsson.com>
|
||||||
|
|
||||||
|
* target.c (target_struct_size): Remove.
|
||||||
|
(target_struct_allocsize): Remove.
|
||||||
|
(DEFAULT_ALLOCSIZE): Remove.
|
||||||
|
(target_ops_p): New typedef.
|
||||||
|
(DEF_VEC_P (target_ops_p)): New vector type.
|
||||||
|
(target_structs): Change type to VEC (target_ops_p).
|
||||||
|
(add_target_with_completer): Replace "push" code by VEC_safe_push.
|
||||||
|
(find_default_run_target): Rewrite for loop following changes to
|
||||||
|
target_structs.
|
||||||
|
|
||||||
2014-08-19 Joel Brobecker <brobecker@adacore.com>
|
2014-08-19 Joel Brobecker <brobecker@adacore.com>
|
||||||
|
|
||||||
* value.c (value_from_pointer): Remove use of resolve_dynamic_type.
|
* value.c (value_from_pointer): Remove use of resolve_dynamic_type.
|
||||||
|
|
36
gdb/target.c
36
gdb/target.c
|
@ -117,13 +117,10 @@ static void init_dummy_target (void);
|
||||||
|
|
||||||
static void update_current_target (void);
|
static void update_current_target (void);
|
||||||
|
|
||||||
/* Pointer to array of target architecture structures; the size of the
|
/* Vector of existing target structures. */
|
||||||
array; the current index into the array; the allocated size of the
|
typedef struct target_ops *target_ops_p;
|
||||||
array. */
|
DEF_VEC_P (target_ops_p);
|
||||||
struct target_ops **target_structs;
|
static VEC (target_ops_p) *target_structs;
|
||||||
unsigned target_struct_size;
|
|
||||||
unsigned target_struct_allocsize;
|
|
||||||
#define DEFAULT_ALLOCSIZE 10
|
|
||||||
|
|
||||||
/* The initial current target, so that there is always a semi-valid
|
/* The initial current target, so that there is always a semi-valid
|
||||||
current target. */
|
current target. */
|
||||||
|
@ -379,20 +376,7 @@ add_target_with_completer (struct target_ops *t,
|
||||||
|
|
||||||
complete_target_initialization (t);
|
complete_target_initialization (t);
|
||||||
|
|
||||||
if (!target_structs)
|
VEC_safe_push (target_ops_p, target_structs, t);
|
||||||
{
|
|
||||||
target_struct_allocsize = DEFAULT_ALLOCSIZE;
|
|
||||||
target_structs = (struct target_ops **) xmalloc
|
|
||||||
(target_struct_allocsize * sizeof (*target_structs));
|
|
||||||
}
|
|
||||||
if (target_struct_size >= target_struct_allocsize)
|
|
||||||
{
|
|
||||||
target_struct_allocsize *= 2;
|
|
||||||
target_structs = (struct target_ops **)
|
|
||||||
xrealloc ((char *) target_structs,
|
|
||||||
target_struct_allocsize * sizeof (*target_structs));
|
|
||||||
}
|
|
||||||
target_structs[target_struct_size++] = t;
|
|
||||||
|
|
||||||
if (targetlist == NULL)
|
if (targetlist == NULL)
|
||||||
add_prefix_cmd ("target", class_run, target_command, _("\
|
add_prefix_cmd ("target", class_run, target_command, _("\
|
||||||
|
@ -2363,15 +2347,15 @@ find_default_run_target (char *do_mesg)
|
||||||
|
|
||||||
if (auto_connect_native_target)
|
if (auto_connect_native_target)
|
||||||
{
|
{
|
||||||
struct target_ops **t;
|
struct target_ops *t;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
for (t = target_structs; t < target_structs + target_struct_size;
|
for (i = 0; VEC_iterate (target_ops_p, target_structs, i, t); ++i)
|
||||||
++t)
|
|
||||||
{
|
{
|
||||||
if ((*t)->to_can_run != delegate_can_run && target_can_run (*t))
|
if (t->to_can_run != delegate_can_run && target_can_run (t))
|
||||||
{
|
{
|
||||||
runable = *t;
|
runable = t;
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue