Make the objfile destructor private
[deliverable/binutils-gdb.git] / gdb / objfiles.h
index 663e6390dcd6f22e5874d99f1c509a243b82fc04..49b4627d67cc5e27370d24cbcc86fc369e15cae6 100644 (file)
@@ -399,13 +399,18 @@ private:
   /* The only way to create an objfile is to call objfile::make.  */
   objfile (bfd *, const char *, objfile_flags);
 
+  /* The only way to free an objfile is via 'unlink'.  */
+  ~objfile ();
+
 public:
 
   /* Create an objfile.  */
   static objfile *make (bfd *bfd_, const char *name_, objfile_flags flags_,
                        objfile *parent = nullptr);
 
-  ~objfile ();
+  /* Remove an objfile from the current program space, and free
+     it.  */
+  void unlink ();
 
   DISABLE_COPY_AND_ASSIGN (objfile);
 
@@ -637,6 +642,20 @@ public:
   htab_up static_links;
 };
 
+/* A deleter for objfile.  */
+
+struct objfile_deleter
+{
+  void operator() (objfile *ptr) const
+  {
+    ptr->unlink ();
+  }
+};
+
+/* A unique pointer that holds an objfile.  */
+
+typedef std::unique_ptr<objfile, objfile_deleter> objfile_up;
+
 /* Declarations for functions defined in objfiles.c */
 
 extern struct gdbarch *get_objfile_arch (const struct objfile *);
This page took 0.023724 seconds and 4 git commands to generate.