MLECO-4260: Replace raw C++ pointers with smart variants

Model:
Added std::unique_ptr qualifier to Model.cc member and
used make_unique when creating interpreter object
Removed custom destructor and un-necessary memory cleanup following
failed allocation

DataStructures:
Refactored array 2d to use a std::vector under the hood.
This should preserve desired attributes including contiguous
memory while removing the need for custom destructor.
Original size function renamed to dimSize to avoid confusion with
vector.size()
Accompanying changes made to preprocessing and ASR tests.

AppContext:
Replaced use of raw pointers in AppContext.hpp.
Previously a std::map including IAttribute pointers required
individual deallocation as they were allocated using new.

Signed-off-by: Liam Barry <liam.barry@arm.com>
Change-Id: I1a34dce5dea6ecf4883a9ada3a20f827eb6e6d6b
diff --git a/source/application/api/common/include/DataStructures.hpp b/source/application/api/common/include/DataStructures.hpp
index 04c00e7..13bf694 100644
--- a/source/application/api/common/include/DataStructures.hpp
+++ b/source/application/api/common/include/DataStructures.hpp
@@ -1,6 +1,6 @@
 /*
- * SPDX-FileCopyrightText: Copyright 2021 Arm Limited and/or its affiliates <open-source-office@arm.com>
- * SPDX-License-Identifier: Apache-2.0
+ * SPDX-FileCopyrightText: Copyright 2021, 2023 Arm Limited and/or its affiliates
+ * <open-source-office@arm.com> SPDX-License-Identifier: Apache-2.0
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
 #define DATA_STRUCTURES_HPP
 
 #include <iterator>
+#include <vector>
 
 namespace arm {
 namespace app {
@@ -49,21 +50,17 @@
         {
             if (rows == 0 || cols == 0) {
                 printf("Array2d constructor has 0 size.\n");
-                m_data = nullptr;
                 return;
             }
-            m_data = new T[rows * cols];
+            m_data = std::vector<T>(rows * cols);
         }
 
-        ~Array2d()
-        {
-            delete[] m_data;
-        }
+        ~Array2d() = default;
 
         T& operator() (unsigned int row, unsigned int col)
         {
 #if defined(DEBUG)
-            if (row >= m_rows || col >= m_cols ||  m_data == nullptr) {
+            if (row >= m_rows || col >= m_cols || m_data.empty()) {
                 printf_err("Array2d subscript out of bounds.\n");
             }
 #endif /* defined(DEBUG) */
@@ -73,7 +70,7 @@
         T operator() (unsigned int row, unsigned int col) const
         {
 #if defined(DEBUG)
-            if (row >= m_rows || col >= m_cols ||  m_data == nullptr) {
+            if (row >= m_rows || col >= m_cols || m_data.empty()) {
                 printf_err("const Array2d subscript out of bounds.\n");
             }
 #endif /* defined(DEBUG) */
@@ -84,7 +81,7 @@
          * @brief  Gets rows number of the current array2d.
          * @return Number of rows.
          */
-        size_t size(size_t dim)
+        size_t dimSize(size_t dim)
         {
             switch (dim)
             {
@@ -111,15 +108,15 @@
         using iterator=T*;
         using const_iterator=T const*;
 
-        iterator begin() { return m_data; }
-        iterator end() { return m_data + totalSize(); }
-        const_iterator begin() const { return m_data; }
-        const_iterator end() const { return m_data + totalSize(); };
+        iterator begin() { return m_data.data(); }
+        iterator end() { return m_data.data() + totalSize(); }
+        const_iterator begin() const { return m_data.data(); }
+        const_iterator end() const { return m_data.data() + totalSize(); };
 
     private:
         size_t m_rows;
         size_t m_cols;
-        T* m_data;
+        std::vector<T> m_data;
     };
 
 } /* namespace app */