pathtrace.c: use xgrowarray
* defs.h <struct path_set>: Change type of num_selected field to size_t. Add size field. * pathtrace.c (storepath): Rewrite to utilise xgrowarray.
This commit is contained in:
parent
f236207f46
commit
bfbfdf5e37
3
defs.h
3
defs.h
@ -364,7 +364,8 @@ extern unsigned int show_fd_path;
|
||||
/* are we filtering traces based on paths? */
|
||||
extern struct path_set {
|
||||
const char **paths_selected;
|
||||
unsigned int num_selected;
|
||||
size_t num_selected;
|
||||
size_t size;
|
||||
} global_path_set;
|
||||
#define tracing_paths (global_path_set.num_selected != 0)
|
||||
extern unsigned xflag;
|
||||
|
13
pathtrace.c
13
pathtrace.c
@ -82,16 +82,15 @@ fdmatch(struct tcb *tcp, int fd, struct path_set *set)
|
||||
static void
|
||||
storepath(const char *path, struct path_set *set)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
if (pathmatch(path, set))
|
||||
return; /* already in table */
|
||||
|
||||
i = set->num_selected++;
|
||||
set->paths_selected = xreallocarray(set->paths_selected,
|
||||
set->num_selected,
|
||||
sizeof(set->paths_selected[0]));
|
||||
set->paths_selected[i] = path;
|
||||
if (set->num_selected >= set->size)
|
||||
set->paths_selected =
|
||||
xgrowarray(set->paths_selected, &set->size,
|
||||
sizeof(set->paths_selected[0]));
|
||||
|
||||
set->paths_selected[set->num_selected++] = path;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user