From bc89af866f2802268b0a1acb6377debd3a45ba65 Mon Sep 17 00:00:00 2001 From: efondere Date: Thu, 8 Jun 2023 17:17:14 -0400 Subject: [PATCH] Use malloc and free and fix some warnings --- ArduinoExtra/Array.h | 2 +- ArduinoExtra/Vector.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ArduinoExtra/Array.h b/ArduinoExtra/Array.h index 419d162..190a5b6 100644 --- a/ArduinoExtra/Array.h +++ b/ArduinoExtra/Array.h @@ -29,7 +29,7 @@ class Array * * Note the array is always full so the size is also the maximum capacity */ - const size_t getSize() + size_t getSize() { return S; } diff --git a/ArduinoExtra/Vector.h b/ArduinoExtra/Vector.h index 71c2348..9304e73 100644 --- a/ArduinoExtra/Vector.h +++ b/ArduinoExtra/Vector.h @@ -58,7 +58,7 @@ class Vector } clear(); - ::operator delete(m_data, m_capacity * sizeof(T)); + free(reinterpret_cast(m_data)); } /** @@ -193,7 +193,7 @@ class Vector * @return true vector is empty * @return false vector is not empty */ - const bool isEmpty() const + bool isEmpty() const { return (m_size == 0); } @@ -207,7 +207,7 @@ class Vector void reAllocate(size_t newCapacity) { // allocate new block of memory - T* newBlock = (T*)::operator new(newCapacity * sizeof(T)); + T* newBlock = reinterpret_cast(malloc(newCapacity * sizeof(T))); if (newCapacity < m_size) { @@ -227,7 +227,7 @@ class Vector } // delete old elements - ::operator delete(m_data, m_capacity * sizeof(T)); + free(reinterpret_cast(m_data)); m_data = newBlock; m_capacity = newCapacity; }