try an other way to create the memory reference point

This commit is contained in:
Thomas Kunze 2019-07-02 23:54:31 +02:00
parent 197203b88e
commit 1321d62e40
4 changed files with 23 additions and 13 deletions

View File

@ -1 +1 @@
0.1.5 0.1.6

View File

@ -11,8 +11,8 @@ uint8_t* Platform::memoryReference()
uint8_t* Platform::allocMemory(size_t size) uint8_t* Platform::allocMemory(size_t size)
{ {
uint8_t* address = (uint8_t*)malloc(size); uint8_t* address = (uint8_t*)malloc(size);
if (_memoryReference == 0) // if (_memoryReference == 0 || address < _memoryReference)
_memoryReference = address; // _memoryReference = address;
return address; return address;
} }
@ -21,3 +21,11 @@ void Platform::freeMemory(uint8_t* ptr)
{ {
free(ptr); free(ptr);
} }
Platform::Platform()
{
// allocate memory to have a memory reference
_memoryReference = (uint8_t*)malloc(1);
free(_memoryReference);
}

View File

@ -7,6 +7,7 @@
class Platform class Platform
{ {
public: public:
Platform();
virtual uint32_t currentIpAddress() = 0; virtual uint32_t currentIpAddress() = 0;
virtual uint32_t currentSubnetMask() = 0; virtual uint32_t currentSubnetMask() = 0;
virtual uint32_t currentDefaultGateway() = 0; virtual uint32_t currentDefaultGateway() = 0;
@ -36,6 +37,7 @@ public:
virtual uint8_t* memoryReference(); virtual uint8_t* memoryReference();
virtual uint8_t* allocMemory(size_t size); virtual uint8_t* allocMemory(size_t size);
virtual void freeMemory(uint8_t* ptr); virtual void freeMemory(uint8_t* ptr);
protected: protected:
uint8_t* _memoryReference = 0; uint8_t* _memoryReference = 0;
}; };