Revised test using private new/delete methods suggested in http://mbed.org/forum/mbed/post/24686/

Dependencies:   mbed

Utility.cpp

Committer:
WiredHome
Date:
2014-06-11
Revision:
0:63f4520f2953

File content as of revision 0:63f4520f2953:


#include "Utility.h"

uint32_t Free() {
    uint32_t max = 50000;
    uint32_t x = max / 2;
    uint32_t min = 0;

    __disable_irq();
    while (min < max-1) {
        void * p = malloc(x);
        if (p) {
            free(p);
            min = x;
        } else {
            max = x;
        }
        x = (max + min)/2;
    }
    __enable_irq();
    return(x);
}