static ClAmsEntityTriggerT *clAmsEntityTriggerFind(ClAmsEntityT *pEntity) { ClUint32T hashKey = 0; ClRcT rc = CL_OK; struct hashStruct *pTemp = NULL; ClAmsEntityTriggerT *pEntityTrigger = NULL; if(!pEntity) return NULL; rc = clCksm32bitCompute((ClUint8T*)pEntity->name.value, pEntity->name.length, &hashKey); CL_ASSERT(rc == CL_OK); hashKey &= CL_AMS_ENTITY_THRESHOLD_BUCKET_MASK; for(pTemp = gClAmsEntityTriggerList.hashTable[hashKey]; pTemp; pTemp = pTemp->pNext) { pEntityTrigger = hashEntry(pTemp, ClAmsEntityTriggerT, hash); if(!memcmp(pEntityTrigger->entity.name.value, pEntity->name.value, pEntity->name.length)) return pEntityTrigger; } return NULL; }
static ClAmsMgmtOIExtendedCacheT *clAmsMgmtOIExtendedCacheFind(struct hashStruct **table, ClCorInstanceIdT instance) { struct hashStruct *iter = NULL; ClUint32T hashKey = entityCacheHashKey(instance); for(iter = table[hashKey]; iter; iter = iter->pNext) { ClAmsMgmtOIExtendedCacheT *entry = hashEntry(iter, ClAmsMgmtOIExtendedCacheT, hash); if(entry->instance == instance) return entry; } return NULL; }
void clDifferenceVectorDestroy(void) { ClUint32T i; for(i = 0; i < CL_DIFFERENCE_VECTOR_TABLE_SIZE; ++i) { struct hashStruct *iter; struct hashStruct *next = NULL; for(iter = differenceVectorTable[i]; iter; iter = next) { ClDifferenceBlockT *block = hashEntry(iter, ClDifferenceBlockT, hash); next = iter->pNext; differenceVectorDelete(block); } differenceVectorTable[i] = NULL; } }
static ClTransportNotifyMapT *findNotifyMap(ClInt32T watchFd, ClInt32T port) { ClUint32T hash = 0; if(port < 0) return NULL; hash = TRANSPORT_NOTIFY_HASH(port); struct hashStruct *iter; for(iter = gNotifyMap[hash]; iter; iter = iter->pNext) { ClTransportNotifyMapT *notify = hashEntry(iter, ClTransportNotifyMapT, hash); ClInt32T cmp = (notify->port == port); if(watchFd >= 0) cmp &= (notify->watchFd == watchFd); if(cmp) return notify; } return NULL; }
static void clAmsMgmtOICacheDestroy(ClAmsEntityTypeT type) { struct hashStruct **table = NULL; ClUint32T i; if(type > CL_AMS_ENTITY_TYPE_MAX) return; clOsalMutexLock(&gClAmsMgmtOICacheMutex); table = gClAmsMgmtOICacheTable[type]; for(i = 0; i < CL_AMS_MGMT_OI_CACHE_MASK; ++i) { struct hashStruct *iter = NULL; struct hashStruct *next = NULL; for(iter = table[i]; iter; iter = next) { ClAmsMgmtOICacheT *entry = hashEntry(iter, ClAmsMgmtOICacheT, hash); next = iter->pNext; clHeapFree(entry); } table[i] = NULL; } clOsalMutexUnlock(&gClAmsMgmtOICacheMutex); }
static ClDifferenceBlockT *differenceVectorFind(ClDifferenceVectorKeyT *key, ClUint32T *pHashKey) { struct hashStruct *iter; ClUint32T hashKey; ClUint32T cksum1 = 0; ClUint32T cksum2 = 0; clCksm32bitCompute((ClUint8T*)key->groupKey->pValue, key->groupKey->length, &cksum1); clCksm32bitCompute((ClUint8T*)key->sectionKey->pValue, key->sectionKey->length, &cksum2); hashKey = (cksum1 ^ cksum2 ) & CL_DIFFERENCE_VECTOR_TABLE_MASK; if(pHashKey) *pHashKey = hashKey; for(iter = differenceVectorTable[hashKey]; iter; iter = iter->pNext) { ClDifferenceBlockT *block = hashEntry(iter, ClDifferenceBlockT, hash); if(block->key.groupKey->length != key->groupKey->length) continue; if(block->key.sectionKey->length != key->sectionKey->length) continue; if(memcmp(block->key.groupKey->pValue, key->groupKey->pValue, key->groupKey->length)) continue; if(memcmp(block->key.sectionKey->pValue, key->sectionKey->pValue, key->sectionKey->length)) continue; return block; } return NULL; }
static void clAmsMgmtOIExtendedCacheDestroy(ClAmsMgmtOIExtendedClassTypeT type) { struct hashStruct **table = NULL; ClUint32T i; if(type >= CL_AMS_MGMT_OI_EXTENDED_CLASS_MAX) return; clOsalMutexLock(&gClAmsMgmtOICacheMutex); table = gClAmsMgmtOIExtendedCacheTable[type]; for(i = 0; i < CL_AMS_MGMT_OI_CACHE_MASK; ++i) { struct hashStruct *iter = NULL; struct hashStruct *next = NULL; for(iter = table[i]; iter; iter = next) { ClAmsMgmtOIExtendedCacheT *entry = hashEntry(iter, ClAmsMgmtOIExtendedCacheT, hash); next = iter->pNext; if(entry->pConfig) clHeapFree(entry->pConfig); clHeapFree(entry); } table[i] = NULL; } clOsalMutexUnlock(&gClAmsMgmtOICacheMutex); }