Skip to content

Add trivial new[] and delete[] operators #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions hardware/arduino/boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,21 @@ atmega8.build.mcu=atmega8
atmega8.build.f_cpu=16000000L
atmega8.build.core=arduino
atmega8.build.variant=standard

##############################################################

adafruit32u4.name=Adafruit Atmega32u4
adafruit32u4.upload.protocol=avr109
adafruit32u4.upload.maximum_size=28672
adafruit32u4.upload.speed=1200
adafruit32u4.bootloader.low_fuses=0xfc
adafruit32u4.bootloader.high_fuses=0xd0
adafruit32u4.bootloader.extended_fuses=0xc3
adafruit32u4.bootloader.path=diskloader
adafruit32u4.bootloader.file=DiskLoader-Leonardo.hex
adafruit32u4.bootloader.unlock_bits=0x3F
adafruit32u4.bootloader.lock_bits=0x2F
adafruit32u4.build.mcu=atmega32u4
adafruit32u4.build.f_cpu=16000000L
adafruit32u4.build.core=arduino
adafruit32u4.build.variant=leonardo
12 changes: 11 additions & 1 deletion hardware/arduino/cores/arduino/new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;};
Expand Down
2 changes: 2 additions & 0 deletions hardware/arduino/cores/arduino/new.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include <stdlib.h>

void * operator new(size_t size);
void * operator new[](size_t size);
void operator delete(void * ptr);
void operator delete[](void * ptr);

__extension__ typedef int __guard __attribute__((mode (__DI__)));

Expand Down