From bb79c5e2c74bd2320c110dd9f2c9a897d546f154 Mon Sep 17 00:00:00 2001 From: Timerix22 Date: Thu, 2 Jun 2022 21:00:17 +0300 Subject: [PATCH] block allocation fixed --- src/Autoarr/Autoarr2_methods.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Autoarr/Autoarr2_methods.hpp b/src/Autoarr/Autoarr2_methods.hpp index ac7da91..9869389 100644 --- a/src/Autoarr/Autoarr2_methods.hpp +++ b/src/Autoarr/Autoarr2_methods.hpp @@ -38,14 +38,18 @@ template void Autoarr2::add(T value) { if(!values){ //values=(T**)malloc(sizeof(T*)); - values=new[sizeof(T*)]; + values=new T*[1]; goto create_block; } else if(block_length==max_block_length){ block_length=0; create_block: - values=(T**)realloc(values,(blocks_count+1)*sizeof(T*)); - values[blocks_count]=new[](max_block_length*sizeof(T)); + T** new_values=new T*[blocks_count+1]; + for(uint32 i=0;i