namespace hashlib {
-#define HASHLIB_SIZE_FACTOR 3
+const int config_size_factor = 3;
// The XOR version of DJB2
// (traditionally 5381 is used as starting value for the djb2 hash)
entries.clear();
counter = other.size();
- int new_size = hashtable_size(HASHLIB_SIZE_FACTOR * counter);
+ int new_size = hashtable_size(config_size_factor * counter);
hashtable.resize(new_size);
- new_size = new_size / HASHLIB_SIZE_FACTOR + 1;
+ new_size = new_size / config_size_factor + 1;
entries.reserve(new_size);
for (auto &it : other)
if (free_list < 0)
{
int i = entries.size();
- int new_size = hashtable_size(HASHLIB_SIZE_FACTOR * entries.size());
+ int new_size = hashtable_size(config_size_factor * entries.size());
hashtable.resize(new_size);
- entries.resize(new_size / HASHLIB_SIZE_FACTOR + 1);
+ entries.resize(new_size / config_size_factor + 1);
entries[i].udata = value;
entries[i].set_next_used(0);
counter++;
entries.clear();
counter = other.size();
- int new_size = hashtable_size(HASHLIB_SIZE_FACTOR * counter);
+ int new_size = hashtable_size(config_size_factor * counter);
hashtable.resize(new_size);
- new_size = new_size / HASHLIB_SIZE_FACTOR + 1;
+ new_size = new_size / config_size_factor + 1;
entries.reserve(new_size);
for (auto &it : other)
if (free_list < 0)
{
int i = entries.size();
- int new_size = hashtable_size(HASHLIB_SIZE_FACTOR * entries.size());
+ int new_size = hashtable_size(config_size_factor * entries.size());
hashtable.resize(new_size);
- entries.resize(new_size / HASHLIB_SIZE_FACTOR + 1);
+ entries.resize(new_size / config_size_factor + 1);
entries[i].key = key;
entries[i].set_next_used(0);
counter++;
#endif
bool memhasher_active = false;
-uint32_t memhasher_rng;
+uint32_t memhasher_rng = 123456;
std::vector<void*> memhasher_store;
void memhasher_on()
{
+#ifdef __linux__
memhasher_rng += time(NULL) << 16 ^ getpid();
+#endif
memhasher_store.resize(0x10000);
memhasher_active = true;
}