Changeset 20236

Show
Ignore:
Timestamp:
05/21/07 14:34:19 (1 year ago)
Author:
aronb
Message:

Fix memory leak in loadKnownDevices and hackLoadKnownDevices.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/trunk/modules/gadgeteer/gadget/Type/BaseTypeFactory.h

    r19729 r20236  
    9191      mConstructors = std::vector<BaseTypeConstructorBase*>(0); 
    9292      vprASSERT(mConstructors.size() == 0); 
     93   } 
     94 
     95   ~BaseTypeFactory() 
     96   { 
     97      for (std::vector<BaseTypeConstructorBase*>::iterator itr = mConstructors.begin(); 
     98           itr != mConstructors.end(); itr++) 
     99      { 
     100         if (NULL != *itr) 
     101         { 
     102            delete *itr; 
     103            *itr = NULL; 
     104         } 
     105      } 
     106      mConstructors.clear(); 
    93107   } 
    94108 
  • juggler/trunk/modules/gadgeteer/gadget/Type/DeviceFactory.h

    r19729 r20236  
    5656   } 
    5757 
     58   ~DeviceFactory() 
     59   { 
     60      for (std::vector<DeviceConstructorBase*>::iterator itr = mConstructors.begin(); 
     61           itr != mConstructors.end(); itr++) 
     62      { 
     63         if (NULL != *itr) 
     64         { 
     65            delete *itr; 
     66            *itr = NULL; 
     67         } 
     68      } 
     69      mConstructors.clear(); 
     70   } 
     71 
    5872   /** 
    5973    * Performs static loading of devices that cannot be loaded through the