20000-05-18 H.J. Lu (hjl@gnu.org)
[binutils-gdb.git] / gdb / utils.c
index abd6ecc397585a6e761ce25d91d12efb79adbe24..45fdb1dd47b8055dd5858fac1ee51e0ccade7802 100644 (file)
@@ -203,6 +203,18 @@ make_cleanup_freeargv (arg)
   return make_my_cleanup (&cleanup_chain, do_freeargv, arg);
 }
 
+static void
+do_bfd_close_cleanup (void *arg)
+{
+  bfd_close (arg);
+}
+
+struct cleanup *
+make_cleanup_bfd_close (bfd *abfd)
+{
+  return make_cleanup (do_bfd_close_cleanup, abfd);
+}
+
 static void
 do_ui_file_delete (void *arg)
 {
@@ -378,8 +390,13 @@ void
 free_current_contents (void *ptr)
 {
   void **location = ptr;
+  if (location == NULL)
+    internal_error ("free_current_contents: NULL pointer");
   if (*location != NULL)
-    free (*location);
+    {
+      free (*location);
+      *location = NULL;
+    }
 }
 
 /* Provide a known function that does nothing, to use as a base for
@@ -3010,20 +3027,3 @@ preg_nz (reg)
     }
   return preg_str;
 }
-
-/* Helper functions for INNER_THAN */
-int
-core_addr_lessthan (lhs, rhs)
-     CORE_ADDR lhs;
-     CORE_ADDR rhs;
-{
-  return (lhs < rhs);
-}
-
-int
-core_addr_greaterthan (lhs, rhs)
-     CORE_ADDR lhs;
-     CORE_ADDR rhs;
-{
-  return (lhs > rhs);
-}