2010-10-17 01:02:06 -03:00
|
|
|
//
|
|
|
|
// C++ runtime support not provided by Arduino
|
|
|
|
//
|
|
|
|
// Note: use new/delete with caution. The heap is small and
|
|
|
|
// easily fragmented.
|
|
|
|
|
2015-08-11 03:28:42 -03:00
|
|
|
#include <AP_HAL/AP_HAL.h>
|
2010-10-17 01:02:06 -03:00
|
|
|
#include <stdlib.h>
|
2012-08-22 21:31:03 -03:00
|
|
|
|
2015-06-26 02:41:11 -03:00
|
|
|
/*
|
|
|
|
globally override new and delete to ensure that we always start with
|
2015-11-03 09:46:29 -04:00
|
|
|
zero memory. This ensures consistent behaviour.
|
2015-06-26 02:41:11 -03:00
|
|
|
*/
|
2010-12-28 19:33:27 -04:00
|
|
|
void * operator new(size_t size)
|
2010-10-17 01:02:06 -03:00
|
|
|
{
|
2015-06-26 02:41:11 -03:00
|
|
|
if (size < 1) {
|
|
|
|
size = 1;
|
|
|
|
}
|
2011-10-28 15:43:43 -03:00
|
|
|
return(calloc(size, 1));
|
2010-10-17 01:02:06 -03:00
|
|
|
}
|
|
|
|
|
2010-12-28 19:33:27 -04:00
|
|
|
void operator delete(void *p)
|
2010-10-17 01:02:06 -03:00
|
|
|
{
|
2011-10-28 15:43:43 -03:00
|
|
|
if (p) free(p);
|
2010-12-23 19:02:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void * operator new[](size_t size)
|
|
|
|
{
|
2015-06-26 02:41:11 -03:00
|
|
|
if (size < 1) {
|
|
|
|
size = 1;
|
|
|
|
}
|
2010-12-28 19:29:46 -04:00
|
|
|
return(calloc(size, 1));
|
2010-12-23 19:02:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void operator delete[](void * ptr)
|
|
|
|
{
|
|
|
|
if (ptr) free(ptr);
|
2010-10-17 01:02:06 -03:00
|
|
|
}
|