From af6d55d68c677a9fa1b009e833f503b8bf1f5b95 Mon Sep 17 00:00:00 2001 From: James Price Date: Tue, 19 Jan 2021 11:35:30 -0500 Subject: [PATCH] Use delete[] to deallocate after new[] (#1107) * Use delete[] to deallocate after new[] * Fixup formatting with git-clang-format --- .../mem_host_flags/C_host_memory_block.h | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/test_conformance/mem_host_flags/C_host_memory_block.h b/test_conformance/mem_host_flags/C_host_memory_block.h index 91b47abf..1d3b4757 100644 --- a/test_conformance/mem_host_flags/C_host_memory_block.h +++ b/test_conformance/mem_host_flags/C_host_memory_block.h @@ -69,31 +69,28 @@ C_host_memory_block::C_host_memory_block() template < class T> C_host_memory_block::~C_host_memory_block() { - if (pData!=NULL) delete pData; - num_elements = 0; + if (pData != NULL) delete[] pData; + num_elements = 0; } template < class T > void C_host_memory_block::Init(int num_elem, T & value) { - if (pData!=NULL) delete pData; - pData= new T [num_elem]; - for (int i=0; i void C_host_memory_block::Init(int num_elem) { - if (pData!=NULL) delete pData; - pData = new T [num_elem]; - for (int i=0; i void C_host_memory_block::Set_to_zero()