From: Simon Marchi Date: Fri, 17 Nov 2017 18:02:24 +0000 (-0500) Subject: Make open_fds an std::vector X-Git-Tag: users/ARM/embedded-binutils-master-2017q4~178 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=37269bc92ca6a79f9e56fe83718f3c86a1db845d;p=external%2Fbinutils.git Make open_fds an std::vector Simple replacement of VEC with std::vector. gdb/ChangeLog: * common/filestuff.c: Include . (open_fds): Change type to std::vector. (do_mark_open_fd): Adjust. (unmark_fd_no_cloexec): Adjust. (do_close): Adjust. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 373ae85..46de331 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,13 @@ 2017-11-17 Simon Marchi + * common/filestuff.c: Include . + (open_fds): Change type to std::vector. + (do_mark_open_fd): Adjust. + (unmark_fd_no_cloexec): Adjust. + (do_close): Adjust. + +2017-11-17 Simon Marchi + * breakpoint.c (output_thread_groups): Take an std::vector. (print_one_breakpoint_location): Adjust. diff --git a/gdb/common/filestuff.c b/gdb/common/filestuff.c index 4b05884..881ee27 100644 --- a/gdb/common/filestuff.c +++ b/gdb/common/filestuff.c @@ -23,6 +23,7 @@ #include #include #include +#include #ifdef USE_WIN32API #include @@ -146,11 +147,10 @@ fdwalk (int (*func) (void *, int), void *arg) -/* A VEC holding all the fds open when notice_open_fds was called. We - don't use a hashtab because libiberty isn't linked into gdbserver; - and anyway we don't expect there to be many open fds. */ +/* A vector holding all the fds open when notice_open_fds was called. We + don't use a hashtab because we don't expect there to be many open fds. */ -static VEC (int) *open_fds; +static std::vector open_fds; /* An fdwalk callback function used by notice_open_fds. It puts the given file descriptor into the vec. */ @@ -158,7 +158,7 @@ static VEC (int) *open_fds; static int do_mark_open_fd (void *ignore, int fd) { - VEC_safe_push (int, open_fds, fd); + open_fds.push_back (fd); return 0; } @@ -183,18 +183,12 @@ mark_fd_no_cloexec (int fd) void unmark_fd_no_cloexec (int fd) { - int i, val; + auto it = std::remove (open_fds.begin (), open_fds.end (), fd); - for (i = 0; VEC_iterate (int, open_fds, i, val); ++i) - { - if (fd == val) - { - VEC_unordered_remove (int, open_fds, i); - return; - } - } - - gdb_assert_not_reached (_("fd not found in open_fds")); + if (it != open_fds.end ()) + open_fds.erase (it); + else + gdb_assert_not_reached (_("fd not found in open_fds")); } /* Helper function for close_most_fds that closes the file descriptor @@ -203,9 +197,7 @@ unmark_fd_no_cloexec (int fd) static int do_close (void *ignore, int fd) { - int i, val; - - for (i = 0; VEC_iterate (int, open_fds, i, val); ++i) + for (int val : open_fds) { if (fd == val) {