Browse Source

added destructor to loaded commands

Ken Martin 23 years ago
parent
commit
0a2f6c876c
2 changed files with 13 additions and 1 deletions
  1. 2 0
      Source/cmCPluginAPI.h
  2. 11 1
      Source/cmLoadCommandCommand.cxx

+ 2 - 0
Source/cmCPluginAPI.h

@@ -176,6 +176,7 @@ Finally we define the key data structures and function prototypes
   typedef int (*CM_INITIAL_PASS_FUNCTION)(void *info, void *mf, 
   typedef int (*CM_INITIAL_PASS_FUNCTION)(void *info, void *mf, 
                                           int argc, char *[]);
                                           int argc, char *[]);
   typedef void (*CM_FINAL_PASS_FUNCTION)(void *info, void *mf);
   typedef void (*CM_FINAL_PASS_FUNCTION)(void *info, void *mf);
+  typedef void (*CM_DESTRUCTOR_FUNCTION)(void *info);
   
   
   typedef struct {
   typedef struct {
     unsigned char magic1;
     unsigned char magic1;
@@ -184,6 +185,7 @@ Finally we define the key data structures and function prototypes
     int m_Inherited;
     int m_Inherited;
     CM_INITIAL_PASS_FUNCTION InitialPass;
     CM_INITIAL_PASS_FUNCTION InitialPass;
     CM_FINAL_PASS_FUNCTION FinalPass;
     CM_FINAL_PASS_FUNCTION FinalPass;
+    CM_DESTRUCTOR_FUNCTION Destructor;
     CM_DOC_FUNCTION GetTerseDocumentation;
     CM_DOC_FUNCTION GetTerseDocumentation;
     CM_DOC_FUNCTION GetFullDocumentation;  
     CM_DOC_FUNCTION GetFullDocumentation;  
     void *ClientData;
     void *ClientData;

+ 11 - 1
Source/cmLoadCommandCommand.cxx

@@ -28,6 +28,9 @@ public:
     this->info.CAPI = &cmStaticCAPI;
     this->info.CAPI = &cmStaticCAPI;
   }
   }
   
   
+  ///! clean up any memory allocated by the plugin
+  ~cmLoadedCommand();
+    
   /**
   /**
    * This is a virtual constructor for the command.
    * This is a virtual constructor for the command.
    */
    */
@@ -139,7 +142,14 @@ void cmLoadedCommand::FinalPass()
     {
     {
     this->info.FinalPass((void *)&this->info,(void *)this->m_Makefile);
     this->info.FinalPass((void *)&this->info,(void *)this->m_Makefile);
     }
     }
-  
+}
+
+cmLoadedCommand::~cmLoadedCommand()
+{
+  if (this->info.Destructor)
+    {
+    this->info.Destructor((void *)&this->info);
+    }
 }
 }
 
 
 // cmLoadCommandCommand
 // cmLoadCommandCommand