| 121 | } |
| 122 | |
| 123 | void NetStringTable::removeString(U32 id, bool script) |
| 124 | { |
| 125 | if(!script) |
| 126 | { |
| 127 | AssertFatal(table[id].refCount != 0, "Error, ref count is already 0!!"); |
| 128 | if(--table[id].refCount) |
| 129 | return; |
| 130 | if(table[id].scriptRefCount) |
| 131 | return; |
| 132 | } |
| 133 | else |
| 134 | { |
| 135 | // If both ref counts are already 0, this id is not valid. Ignore |
| 136 | // the remove |
| 137 | if (table[id].scriptRefCount == 0 && table[id].refCount == 0) |
| 138 | return; |
| 139 | |
| 140 | if(table[id].scriptRefCount == 0 && table[id].refCount) |
| 141 | { |
| 142 | Con::errorf("removeTaggedString failed! Ref count is already 0 for string: %s", table[id].string); |
| 143 | return; |
| 144 | } |
| 145 | if(--table[id].scriptRefCount) |
| 146 | return; |
| 147 | if(table[id].refCount) |
| 148 | return; |
| 149 | } |
| 150 | // unlink first: |
| 151 | U32 prev = table[id].prevLink; |
| 152 | U32 next = table[id].link; |
| 153 | if(next) |
| 154 | table[next].prevLink = prev; |
| 155 | if(prev) |
| 156 | table[prev].link = next; |
| 157 | else |
| 158 | firstValid = next; |
| 159 | // remove it from the hash table |
| 160 | U32 hash = _StringTable::hashString(table[id].string); |
| 161 | U32 bucket = hash % HashTableSize; |
| 162 | for(U32 *walk = &hashTable[bucket];*walk; walk = &table[*walk].next) |
| 163 | { |
| 164 | if(*walk == id) |
| 165 | { |
| 166 | *walk = table[id].next; |
| 167 | break; |
| 168 | } |
| 169 | } |
| 170 | table[id].next = firstFree; |
| 171 | firstFree = id; |
| 172 | } |
| 173 | |
| 174 | void NetStringTable::repack() |
| 175 | { |
no test coverage detected