microbit: Added support for MicroBitHeapAllocator to allocate C++ style array

declarations

Added missing operator new[] wrapper in MicroBitHeapAllocator.h
Ammended defualt microBitConfig.h to allocate 90% of available heap, rather
than 95%. this is to leave a little more heap for external libraries.
This commit is contained in:
Joe Finney 2016-01-09 11:33:02 +00:00
parent 6916d506b8
commit 92905593f1
2 changed files with 9 additions and 1 deletions

View File

@ -39,7 +39,7 @@
// The proportion of SRAM available on the mbed heap to reserve for the micro:bit heap.
#ifndef MICROBIT_HEAP_SIZE
#define MICROBIT_HEAP_SIZE 0.25
#define MICROBIT_HEAP_SIZE 0.9
#endif
// if defined, reuse the 8K of SRAM reserved for SoftDevice (Nordic's memory resident BLE stack) as heap memory.

View File

@ -91,6 +91,14 @@ inline void* operator new(size_t size) throw(std::bad_alloc)
return microbit_malloc(size);
}
/**
* Overrides the 'new' operator globally, and redirects calls to the micro:bit theap allocator.
*/
inline void* operator new[](size_t size) throw(std::bad_alloc)
{
return microbit_malloc(size);
}
/**
* Overrides the 'delete' operator globally, and redirects calls to the micro:bit theap allocator.
*/