* @name AddProtoToClass * * Add a new proto to this class. Malloc new space and copy the * old protos if necessary. Return the proto id for the new proto. * * @param Class The class to add to */
| 97 | * @param Class The class to add to |
| 98 | */ |
| 99 | int AddProtoToClass(CLASS_TYPE Class) { |
| 100 | int i; |
| 101 | int Bit; |
| 102 | int NewNumProtos; |
| 103 | int NewProto; |
| 104 | BIT_VECTOR Config; |
| 105 | |
| 106 | if (Class->NumProtos >= Class->MaxNumProtos) { |
| 107 | /* add protos in PROTO_INCREMENT chunks at a time */ |
| 108 | NewNumProtos = (((Class->MaxNumProtos + PROTO_INCREMENT) / |
| 109 | PROTO_INCREMENT) * PROTO_INCREMENT); |
| 110 | |
| 111 | Class->Prototypes = (PROTO) Erealloc (Class->Prototypes, |
| 112 | sizeof (PROTO_STRUCT) * |
| 113 | NewNumProtos); |
| 114 | |
| 115 | Class->MaxNumProtos = NewNumProtos; |
| 116 | |
| 117 | for (i = 0; i < Class->NumConfigs; i++) { |
| 118 | Config = Class->Configurations[i]; |
| 119 | Class->Configurations[i] = ExpandBitVector (Config, NewNumProtos); |
| 120 | |
| 121 | for (Bit = Class->NumProtos; Bit < NewNumProtos; Bit++) |
| 122 | reset_bit(Config, Bit); |
| 123 | } |
| 124 | } |
| 125 | NewProto = Class->NumProtos++; |
| 126 | if (Class->NumProtos > MAX_NUM_PROTOS) { |
| 127 | tprintf("Ouch! number of protos = %d, vs max of %d!", |
| 128 | Class->NumProtos, MAX_NUM_PROTOS); |
| 129 | } |
| 130 | return (NewProto); |
| 131 | } |
| 132 | |
| 133 | |
| 134 | /** |
nothing calls this directly
no test coverage detected