Some tweaks in makefile

This commit is contained in:
2023-08-25 07:26:23 +03:00
parent c1c1970d04
commit c12682dd2a
3 changed files with 13 additions and 12 deletions

View File

@@ -166,22 +166,20 @@ class KLDRArray {
return false;
}
// Add new cell to array, fast version without keys check
// Add new cell to array, fast version without key checks
void AddF (KeyT key, LengthT length, void* data) {
this->Keys.push_back(key);
this->Lengths.push_back(length);
void* newData = operator new(length); // Yes, allocating memory for void pointer really looks like this
std::copy((uint8_t*)data, (uint8_t*)data + length, (uint8_t*)newData); // Dirty hacks, YES!
std::copy((char*)data, (char*)data + length, (char*)newData); // Dirty hacks, YES!
this->Values.push_back(newData);
// NOTICE: there is `std::is_pod<SomeType>()`, so may be we can use one more template to make this a little more safe (may be)
}
// Add new cell to array, but only if key is unique
void Add (KeyT key, LengthT length, void* data) {
for (size_t i = 0; i < this->CellsAmount(); i++) {
if (this->Keys[i] == key) {
if (this->KeyExists(key))
throw std::invalid_argument("supplied key already exist");
}
}
this->AddF(key, length, data);
}