Hendrik Lipka
/
malloc_test
program to find out whether malloc() returns NULL on a failed call or not
main.cpp@0:77b549539791, 2010-12-21 (annotated)
- Committer:
- hlipka
- Date:
- Tue Dec 21 20:29:11 2010 +0000
- Revision:
- 0:77b549539791
- Child:
- 1:602fea3e6f8b
initial version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hlipka | 0:77b549539791 | 1 | #include "mbed.h" |
hlipka | 0:77b549539791 | 2 | |
hlipka | 0:77b549539791 | 3 | #define MALLOC_SIZE 0x2000 |
hlipka | 0:77b549539791 | 4 | |
hlipka | 0:77b549539791 | 5 | DigitalOut led1(LED1); |
hlipka | 0:77b549539791 | 6 | DigitalOut led2(LED2); |
hlipka | 0:77b549539791 | 7 | DigitalOut led3(LED3); |
hlipka | 0:77b549539791 | 8 | DigitalOut led4(LED4); |
hlipka | 0:77b549539791 | 9 | |
hlipka | 0:77b549539791 | 10 | int main() { |
hlipka | 0:77b549539791 | 11 | led1=0; |
hlipka | 0:77b549539791 | 12 | led2=0; |
hlipka | 0:77b549539791 | 13 | led3=0; |
hlipka | 0:77b549539791 | 14 | led4=0; |
hlipka | 0:77b549539791 | 15 | printf("doing malloc 1\n"); |
hlipka | 0:77b549539791 | 16 | malloc(MALLOC_SIZE); |
hlipka | 0:77b549539791 | 17 | led1=1; |
hlipka | 0:77b549539791 | 18 | printf("doing malloc 2\n"); |
hlipka | 0:77b549539791 | 19 | malloc(MALLOC_SIZE); |
hlipka | 0:77b549539791 | 20 | led2=1; |
hlipka | 0:77b549539791 | 21 | printf("doing malloc 3\n"); |
hlipka | 0:77b549539791 | 22 | malloc(MALLOC_SIZE); |
hlipka | 0:77b549539791 | 23 | led3=1; |
hlipka | 0:77b549539791 | 24 | printf("doing malloc 4\n"); |
hlipka | 0:77b549539791 | 25 | malloc(MALLOC_SIZE); |
hlipka | 0:77b549539791 | 26 | led4=1; |
hlipka | 0:77b549539791 | 27 | printf("finished\n"); |
hlipka | 0:77b549539791 | 28 | } |