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

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
hlipka
Date:
Tue Dec 21 20:29:11 2010 +0000
Child:
1:602fea3e6f8b
Commit message:
initial version

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 21 20:29:11 2010 +0000
@@ -0,0 +1,28 @@
+#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");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Dec 21 20:29:11 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e