Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <stdlib.h>
00011 #include "c++.h"
00012 #include "WProgram.h"
00013
00014 void * operator new(size_t size)
00015 {
00016 return(calloc(size, 1));
00017 }
00018
00019 void operator delete(void *p)
00020 {
00021 if (p) free(p);
00022 }
00023
00024 void * operator new[](size_t size)
00025 {
00026 return malloc(size);
00027 }
00028
00029 void operator delete[](void * ptr)
00030 {
00031 if (ptr) free(ptr);
00032 }
00033
00034 __extension__ typedef int __guard __attribute__((mode (__DI__)));
00035
00036 int __cxa_guard_acquire(__guard *g)
00037 {
00038 return !*(char *)(g);
00039 };
00040
00041 void __cxa_guard_release (__guard *g)
00042 {
00043 *(char *)g = 1;
00044 };
00045
00046 void __cxa_guard_abort (__guard *) {};
00047
00048
00049 extern unsigned int __bss_end;
00050 extern void *__brkval;
00051
00052 void displayMemory()
00053 {
00054 static int minMemFree=0;
00055 if (minMemFree<=0 || freeMemory()<minMemFree) {
00056 minMemFree = freeMemory();
00057 Serial.print("bytes free: ");
00058 Serial.println(minMemFree);
00059 }
00060 }
00061
00062 int freeMemory()
00063 {
00064 int free_memory;
00065
00066 if ((int)__brkval == 0)
00067 free_memory = ((int)&free_memory) - ((int)&__bss_end);
00068 else
00069 free_memory = ((int)&free_memory) - ((int)__brkval);
00070
00071 return free_memory;
00072 }