From b4b9b329552b30a1c76fc843446f6780dab5876d Mon Sep 17 00:00:00 2001 From: hyzboy Date: Sun, 27 Sep 2020 21:15:30 +0800 Subject: [PATCH] AutoDeleteArray append a new construct function. --- inc/hgl/type/Smart.h | 5 +++++ src/FileSystem/FileSystem.cpp | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/inc/hgl/type/Smart.h b/inc/hgl/type/Smart.h index e0d0ac9..d620438 100644 --- a/inc/hgl/type/Smart.h +++ b/inc/hgl/type/Smart.h @@ -518,6 +518,11 @@ namespace hgl obj=nullptr; } + AutoDeleteArray(const size_t count) + { + obj=new T[count]; + } + AutoDeleteArray(T *o) { obj=o; diff --git a/src/FileSystem/FileSystem.cpp b/src/FileSystem/FileSystem.cpp index 23b871e..e3fd8d4 100644 --- a/src/FileSystem/FileSystem.cpp +++ b/src/FileSystem/FileSystem.cpp @@ -33,8 +33,8 @@ namespace hgl return(false); int64 pos=0,size; - AutoDeleteArray data1=new char[buf_size]; - AutoDeleteArray data2=new char[buf_size]; + AutoDeleteArray data1(buf_size); + AutoDeleteArray data2(buf_size); while(pos