---------------------------------------------------------------------- F u n c t i o n s ----------------------------------------------------------------------*/ * @name AddConfigToClass * * Add a new config to this class. Malloc new space and copy the * old configs if necessary. Return the config id for the new config. * * @param Class The class to add to */
| 61 | * @param Class The class to add to |
| 62 | */ |
| 63 | int AddConfigToClass(CLASS_TYPE Class) { |
| 64 | int NewNumConfigs; |
| 65 | int NewConfig; |
| 66 | int MaxNumProtos; |
| 67 | BIT_VECTOR Config; |
| 68 | |
| 69 | MaxNumProtos = Class->MaxNumProtos; |
| 70 | |
| 71 | if (Class->NumConfigs >= Class->MaxNumConfigs) { |
| 72 | /* add configs in CONFIG_INCREMENT chunks at a time */ |
| 73 | NewNumConfigs = (((Class->MaxNumConfigs + CONFIG_INCREMENT) / |
| 74 | CONFIG_INCREMENT) * CONFIG_INCREMENT); |
| 75 | |
| 76 | Class->Configurations = |
| 77 | (CONFIGS) Erealloc (Class->Configurations, |
| 78 | sizeof (BIT_VECTOR) * NewNumConfigs); |
| 79 | |
| 80 | Class->MaxNumConfigs = NewNumConfigs; |
| 81 | } |
| 82 | NewConfig = Class->NumConfigs++; |
| 83 | Config = NewBitVector (MaxNumProtos); |
| 84 | Class->Configurations[NewConfig] = Config; |
| 85 | zero_all_bits (Config, WordsInVectorOfSize (MaxNumProtos)); |
| 86 | |
| 87 | return (NewConfig); |
| 88 | } |
| 89 | |
| 90 | |
| 91 | /** |
nothing calls this directly
no test coverage detected