MCPcopy Create free account
hub / github.com/F-Stack/f-stack / HashRemove

Method HashRemove

adapter/micro_thread/hash_list.h:150–173  ·  view source on GitHub ↗

* @brief hash remove key. */

Source from the content-addressed store, hash-verified

148 * @brief hash remove key.
149 */
150 void HashRemove(HashKey* key) {
151 if (!key || !_buckets) {
152 return;
153 }
154
155 uint32_t hash = key->HashValue();
156 int idx = hash % _max;
157 HashKey* item = _buckets[idx];
158 HashKey* prev = NULL;
159
160 for (; item != NULL; prev = item, item = item->_next_entry) {
161 if ((item->_hash_value == hash) && (item->HashCmp(key) == 0)){
162 if (prev == NULL) {
163 _buckets[idx] = item->_next_entry;
164 } else {
165 prev->_next_entry = item->_next_entry;
166 }
167 item->_hash_value = 0;
168 item->_next_entry = NULL;
169 _count--;
170 break;
171 }
172 }
173 }
174
175 /**
176 * @brief hash loop.

Callers 5

RemoveSessionMethod · 0.80
RemoveNetItemMethod · 0.80
RemoveDestLinkMethod · 0.80
~MsgBuffPoolMethod · 0.80
GetMsgBufMethod · 0.80

Calls 2

HashValueMethod · 0.45
HashCmpMethod · 0.45

Tested by

no test coverage detected