in >> token;
if ( token == '{' ) {
+ // Read the data into a temporary but stack allocated
+ // copy of the structure
+ FGNewMat tmp;
+ in >> tmp;
+
+ // create a pointer to a heap allocated copy of the structure
FGNewMat *m = new FGNewMat;
- in >> *m;
+ *m = tmp;
// build the ssgSimpleState
SGPath tex_path( globals->get_fg_root() );
// Destructor
FGMaterialLib::~FGMaterialLib ( void ) {
+ // Free up all the material entries first
+ for ( material_map_iterator it = begin(); it != end(); it++ ) {
+ FGNewMat *slot = it->second;
+ if ( slot != NULL ) {
+ delete slot;
+ }
+ }
}