program to find out whether malloc() returns NULL on a failed call or not

Dependencies:   mbed

main.cpp

Committer:
hlipka
Date:
2010-12-21
Revision:
0:77b549539791
Child:
1:602fea3e6f8b

File content as of revision 0:77b549539791:

#include "mbed.h"

#define MALLOC_SIZE 0x2000

DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);

int main() {
        led1=0;
        led2=0;
        led3=0;
        led4=0;
        printf("doing malloc 1\n");
        malloc(MALLOC_SIZE);
        led1=1;
        printf("doing malloc 2\n");
        malloc(MALLOC_SIZE);
        led2=1;
        printf("doing malloc 3\n");
        malloc(MALLOC_SIZE);
        led3=1;
        printf("doing malloc 4\n");
        malloc(MALLOC_SIZE);
        led4=1;
        printf("finished\n");
}