From c04e639a15d1dc0220059fd0366bb0aa3e9e3016 Mon Sep 17 00:00:00 2001 From: Tijmen van Nesselrooij Date: Mon, 29 Apr 2019 17:48:35 +0200 Subject: [PATCH] Fix allocation size vector --- random-access-containers/vector.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/random-access-containers/vector.hpp b/random-access-containers/vector.hpp index 4169c8f..5d106bf 100644 --- a/random-access-containers/vector.hpp +++ b/random-access-containers/vector.hpp @@ -1,4 +1,3 @@ -#include #include #include @@ -12,7 +11,7 @@ protected: public: void Resize(std::size_t const newSize) { - void * result = std::realloc(data, newSize); + void * result = std::realloc(data, newSize * sizeof(T)); if(result == nullptr) { throw std::runtime_error("Cannot allocate the requested size of memory.");