diff --git a/src/sequential/vector.hpp b/src/sequential/vector.hpp index 1ea3618..3a78446 100644 --- a/src/sequential/vector.hpp +++ b/src/sequential/vector.hpp @@ -7,7 +7,6 @@ class Vector { private: T * data; - std::size_t byteSize; std::size_t reserveSize; std::size_t size; @@ -17,27 +16,21 @@ private: { std::free(data); data = nullptr; - byteSize = 0ul; reserveSize = 0ul; return; } - std::size_t newByteSize = allocationSize * sizeof(T); - newByteSize += newByteSize % 32ul; // Allocate in blocks of 32 bytes - - if(newByteSize <= byteSize) + if(allocationSize == size) { - reserveSize = allocationSize; return; } - void * result = std::realloc(data, newByteSize); + void * result = std::realloc(data, sizeof(T) * allocationSize); if(result == nullptr) { throw std::runtime_error("Cannot allocate the requested size of memory."); } - byteSize = newByteSize; reserveSize = allocationSize; data = reinterpret_cast(result); } @@ -82,7 +75,6 @@ public: Vector() : data(nullptr), - byteSize(0ul), reserveSize(0ul), size(0ul) {}