Skip to content

Commit

Permalink
Use malloc and free and fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
efondere committed Jun 8, 2023
1 parent d6375ec commit bc89af8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ArduinoExtra/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions ArduinoExtra/Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Vector
}

clear();
::operator delete(m_data, m_capacity * sizeof(T));
free(reinterpret_cast<void*>(m_data));
}

/**
Expand Down Expand Up @@ -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);
}
Expand All @@ -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<T*>(malloc(newCapacity * sizeof(T)));

if (newCapacity < m_size)
{
Expand All @@ -227,7 +227,7 @@ class Vector
}

// delete old elements
::operator delete(m_data, m_capacity * sizeof(T));
free(reinterpret_cast<void*>(m_data));
m_data = newBlock;
m_capacity = newCapacity;
}
Expand Down

0 comments on commit bc89af8

Please sign in to comment.