David Smart / Mbed 2 deprecated mbed_blinky_eats_memory

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Utility.cpp Source File

Utility.cpp

00001 
00002 #include "Utility.h"
00003 
00004 uint32_t Free() {
00005     uint32_t max = 50000;
00006     uint32_t x = max / 2;
00007     uint32_t min = 0;
00008 
00009     __disable_irq();
00010     while (min < max-1) {
00011         void * p = malloc(x);
00012         if (p) {
00013             free(p);
00014             min = x;
00015         } else {
00016             max = x;
00017         }
00018         x = (max + min)/2;
00019     }
00020     __enable_irq();
00021     return(x);
00022 }