aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2012-12-16 14:30:12 +0100
committerCristian Maglie <c.maglie@bug.st>2012-12-16 14:30:12 +0100
commit09b755fb9c3f5c42fa9b38ffeef0dbfa2cfd8315 (patch)
tree59fefe94f7d2174e3a0fcb33234151920b89515c
parent025ec2bc84211a42a3be5e15e44054ba482bf5a0 (diff)
Add trivial new[] and delete[] operators (Justin R. Cutler)
Fixes #73 Fixes #883
-rw-r--r--cores/arduino/new.cpp12
-rw-r--r--cores/arduino/new.h4
2 files changed, 14 insertions, 2 deletions
diff --git a/cores/arduino/new.cpp b/cores/arduino/new.cpp
index 0f6d422..b81031e 100644
--- a/cores/arduino/new.cpp
+++ b/cores/arduino/new.cpp
@@ -5,10 +5,20 @@ void * operator new(size_t size)
return malloc(size);
}
+void * operator new[](size_t size)
+{
+ return malloc(size);
+}
+
void operator delete(void * ptr)
{
free(ptr);
-}
+}
+
+void operator delete[](void * ptr)
+{
+ free(ptr);
+}
int __cxa_guard_acquire(__guard *g) {return !*(char *)(g);};
void __cxa_guard_release (__guard *g) {*(char *)g = 1;};
diff --git a/cores/arduino/new.h b/cores/arduino/new.h
index cd940ce..991c86c 100644
--- a/cores/arduino/new.h
+++ b/cores/arduino/new.h
@@ -8,7 +8,9 @@
#include <stdlib.h>
void * operator new(size_t size);
-void operator delete(void * ptr);
+void * operator new[](size_t size);
+void operator delete(void * ptr);
+void operator delete[](void * ptr);
__extension__ typedef int __guard __attribute__((mode (__DI__)));