ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-1.0/libBASS/Globals.cpp
(Generate patch)

Comparing trunk/OOPSE-1.0/libBASS/Globals.cpp (file contents):
Revision 1419 by gezelter, Tue Jul 27 18:14:16 2004 UTC vs.
Revision 1435 by tim, Thu Jul 29 18:16:16 2004 UTC

# Line 73 | Line 73 | Globals::Globals(){
73   #define G_FORCEFIELD_VARIANT 52
74  
75   Globals::Globals(){
76 <  
76 >  initalize();
77 > }
78 >
79 > Globals::~Globals(){
80    int i;
81  
82 +  for( i=0; i<hash_size; i++ ){
83 +    if( command_table[i] != NULL ) delete command_table[i];
84 +  }
85 +  delete[] command_table;
86 +
87 +  if( components != NULL ){
88 +    for( i=0; i<n_components; i++ ) delete components[i];
89 +    delete[] components;
90 +  }
91 + }
92 +
93 + void Globals::initalize(){
94 +  int i;
95 +  
96    hash_size = 23;
97    hash_shift = 4;
98    
# Line 83 | Line 100 | Globals::Globals(){
100    
101    command_table = new LinkedCommand*[hash_size];
102    for( i=0; i<hash_size; i++ ) command_table[i] = NULL;
103 <
103 >  
104    addHash( "forceField",    G_FORCEFIELD );
105    addHash( "nComponents",   G_NCOMPONENTS );
106    addHash( "targetTemp",    G_TARGETTEMP );
107    addHash( "ensemble",      G_ENSEMBLE );
108 <
108 >  
109    addHash( "dt",            G_DT );
110    addHash( "runTime",       G_RUNTIME );
111 <
111 >  
112    addHash( "initialConfig", G_INITIALCONFIG );
113    addHash( "finalConfig",   G_FINALCONFIG );
114    addHash( "nMol",          G_NMOL );
# Line 198 | Line 215 | Globals::Globals(){
215  
216   }
217  
201 Globals::~Globals(){
202  int i;
203
204  for( i=0; i<hash_size; i++ ){
205    if( command_table[i] != NULL ) delete command_table[i];
206  }
207  delete[] command_table;
208
209  if( components != NULL ){
210    for( i=0; i<n_components; i++ ) delete components[i];
211    delete[] components;
212  }
213 }
214
218   int Globals::newComponent( event* the_event ){
219    
220    current_component = new Component;
# Line 1820 | Line 1823 | void Globals::addHash( char* text, int token ){
1823    the_element->setValues( text, token );
1824  
1825    key = hash( text );
1826 +
1827    the_element->setNext( command_table[key] );
1828    command_table[key] = the_element;
1829   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines