Skip to content

Instantly share code, notes, and snippets.

@jtomschroeder
Created March 13, 2013 18:02
Show Gist options
  • Save jtomschroeder/5154598 to your computer and use it in GitHub Desktop.
Save jtomschroeder/5154598 to your computer and use it in GitHub Desktop.
Arduino new/delete operations: Include these two operator overloads to add new and delete to your Arduino project.
#include <stdlib.h>
void* operator new(size_t size)
{
return malloc(size);
}
void operator delete(void *ptr)
{
if (ptr)
free(ptr);
}
@ValdisB
Copy link

ValdisB commented Jan 29, 2017

Thanks a lot, Tom,
it's the best I have found in i-net for the year!

In fact, yours decision is only one and the first correct working on my Arduino UNO rev. 3,
but before I tried many others, too unsuccessfully,

I even made the library, replaced Arduino' s standart and tested all the night
creating / deleting new class -es even in the Arduino's basic loop() cycle.

OK, so fare, congratulations!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment