]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Code cleanup: dwarf2read.c: Eliminate ::file_write
authorPedro Alves <palves@redhat.com>
Fri, 9 Jun 2017 23:53:00 +0000 (00:53 +0100)
committerPedro Alves <palves@redhat.com>
Mon, 12 Jun 2017 16:06:25 +0000 (17:06 +0100)
There's no real need for all this indirection.

gdb/ChangeLog:
2017-06-12  Pedro Alves  <palves@redhat.com>

* dwarf2read.c (file_write(FILE *, const void *, size_t)): Delete.
(file_write (FILE *, const std::vector<Elem>&)): Delete.
(data_buf::file_write): Call ::fwrite directly.

gdb/ChangeLog
gdb/dwarf2read.c

index 316e03af7c901076385eea288df9edfb479a5a8b..e3e980dfa90d3c272e6b65b1f46f083b258544aa 100644 (file)
@@ -1,3 +1,9 @@
+2017-06-12  Pedro Alves  <palves@redhat.com>
+
+       * dwarf2read.c (file_write(FILE *, const void *, size_t)): Delete.
+       (file_write (FILE *, const std::vector<Elem>&)): Delete.
+       (data_buf::file_write): Call ::fwrite directly.
+
 2017-06-12  Pedro Alves  <palves@redhat.com>
 
        * dwarf2read.c (uniquify_cu_indices): Use std::unique and
index 0c9e275850fad139a89123b6e04d86dc6d72d4fb..55b303348115f6c93b526781182ac5b647fe1fc4 100644 (file)
@@ -23195,25 +23195,6 @@ dwarf2_per_objfile_free (struct objfile *objfile, void *d)
 \f
 /* The "save gdb-index" command.  */
 
-/* Write SIZE bytes from the buffer pointed to by DATA to FILE, with
-   error checking.  */
-
-static void
-file_write (FILE *file, const void *data, size_t size)
-{
-  if (fwrite (data, 1, size, file) != size)
-    error (_("couldn't data write to file"));
-}
-
-/* Write the contents of VEC to FILE, with error checking.  */
-
-template<class Elem>
-static void
-file_write (FILE *file, const std::vector<Elem> &vec)
-{
-  file_write (file, vec.data (), vec.size() * sizeof (vec[0]));
-}
-
 /* In-memory buffer to prepare data to be written later to a file.  */
 class data_buf
 {
@@ -23252,7 +23233,8 @@ public:
   /* Write the buffer to FILE.  */
   void file_write (FILE *file) const
   {
-    ::file_write (file, m_vec);
+    if (::fwrite (m_vec.data (), 1, m_vec.size (), file) != m_vec.size ())
+      error (_("couldn't write data to file"));
   }
 
 private: