Use auto_obstack in windows-nat.c
authorTom Tromey <tromey@adacore.com>
Thu, 31 Mar 2022 15:45:23 +0000 (09:45 -0600)
committerTom Tromey <tromey@adacore.com>
Mon, 4 Apr 2022 19:58:37 +0000 (13:58 -0600)
One spot in windows-nat.c can use auto_obstack, removing some manual
memory management.

gdb/windows-nat.c

index 1e34651a8eff82e0b707e8bf5b6f31c7f2d744a9..74f73614c47568607d9eea54668cdad7de0501a3 100644 (file)
@@ -2877,14 +2877,13 @@ windows_xfer_shared_libraries (struct target_ops *ops,
                               ULONGEST offset, ULONGEST len,
                               ULONGEST *xfered_len)
 {
-  struct obstack obstack;
+  auto_obstack obstack;
   const char *buf;
   LONGEST len_avail;
 
   if (writebuf)
     return TARGET_XFER_E_IO;
 
-  obstack_init (&obstack);
   obstack_grow_str (&obstack, "<library-list>\n");
   for (windows_solib &so : solibs)
     windows_xfer_shared_library (so.name.c_str (),
@@ -2904,7 +2903,6 @@ windows_xfer_shared_libraries (struct target_ops *ops,
       memcpy (readbuf, buf + offset, len);
     }
 
-  obstack_free (&obstack, NULL);
   *xfered_len = (ULONGEST) len;
   return len != 0 ? TARGET_XFER_OK : TARGET_XFER_EOF;
 }