|
摘自PHP的HASH算法实现(5) return -1; } } } p = (LPHASHBUCKET)malloc(sizeof(HASHBUCKET) - 1 + key_length); if (!p) { return -1; } memcpy(p->key, key, key_length); p->key_length = key_length; p->h = h; p->data = data; p->conflict_next = 0; p->conflict_previous = pht->buckets[index]; if (p->conflict_previous) { p->conflict_previous->conflict_next = p; } p->previous = pht->tail; p->next = 0; pht->tail = p; if (p->previous) { p->previous->next = p; } if (!pht->head) { pht->head = p; } pht->buckets[index] = p; ++pht->elements; if (pht->elements > pht->table_size) { hash_do_resize(pht); } return 0; } int hash_find(LPHASHTABLE pht, char *key, unsigned int key_length, void **data)
|