From f042532cc45b763942ffff337e6b20c9f864525b Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Wed, 7 Feb 2001 03:44:24 +0000 Subject: [PATCH] * sol-thread.c (restore_inferior_pid): Save the PID in a freshly allocated buffer. (save_inferior_pid): Restore the PID from that tempoary buffer. Delete the buffer. * utils.c (make_cleanup_close, do_close_cleanup): Ditto for FD. --- gdb/ChangeLog | 8 ++++++++ gdb/sol-thread.c | 10 +++++++--- gdb/utils.c | 9 ++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5aa2f11ac3e..a8091353997 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2001-02-06 Andrew Cagney + + * sol-thread.c (restore_inferior_pid): Save the PID in a freshly + allocated buffer. + (save_inferior_pid): Restore the PID from that tempoary + buffer. Delete the buffer. + * utils.c (make_cleanup_close, do_close_cleanup): Ditto for FD. + 2001-02-06 Andrew Cagney * MAINTAINERS: Add ``The Obvious Fix Rule''. diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index f7727b483d8..f266902f78e 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -424,13 +424,17 @@ lwp_to_thread (int lwp) static struct cleanup * save_inferior_pid (void) { - return make_cleanup (restore_inferior_pid, (void *) inferior_pid); + int *saved_pid = xmalloc (sizeof (int)); + *saved_pid = inferior_pid; + return make_cleanup (restore_inferior_pid, saved_pid); } static void -restore_inferior_pid (void *pid) +restore_inferior_pid (void *data) { - inferior_pid = (int) pid; + int *saved_pid = data; + inferior_pid = *saved_pid; + xfree (saved_pid); } diff --git a/gdb/utils.c b/gdb/utils.c index 0d89cb7b561..164bc9c1648 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -215,14 +215,17 @@ make_cleanup_bfd_close (bfd *abfd) static void do_close_cleanup (void *arg) { - close ((int) arg); + int *fd = arg; + close (*fd); + xfree (fd); } struct cleanup * make_cleanup_close (int fd) { - /* int into void*. Outch!! */ - return make_cleanup (do_close_cleanup, (void *) fd); + int *saved_fd = xmalloc (sizeof (fd)); + *saved_fd = fd; + return make_cleanup (do_close_cleanup, saved_fd); } static void -- 2.30.2