Utility library. Some string and mbed memory utilities.
Dependents: 19E042PIM_T3_2020_0639
mbedUtils.cpp@0:3d93ff64fdee, 2011-06-19 (annotated)
- Committer:
- Phlaphead
- Date:
- Sun Jun 19 13:13:00 2011 +0000
- Revision:
- 0:3d93ff64fdee
Initial Revision
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Phlaphead | 0:3d93ff64fdee | 1 | |
Phlaphead | 0:3d93ff64fdee | 2 | #include "mbedUtils.h" |
Phlaphead | 0:3d93ff64fdee | 3 | |
Phlaphead | 0:3d93ff64fdee | 4 | #include "mbed.h" |
Phlaphead | 0:3d93ff64fdee | 5 | |
Phlaphead | 0:3d93ff64fdee | 6 | |
Phlaphead | 0:3d93ff64fdee | 7 | int getFreeMemory() |
Phlaphead | 0:3d93ff64fdee | 8 | { |
Phlaphead | 0:3d93ff64fdee | 9 | // Return the difference between the heap pointer and stack pointer. |
Phlaphead | 0:3d93ff64fdee | 10 | char stackVar = '\0'; |
Phlaphead | 0:3d93ff64fdee | 11 | char* stackPtr = &stackVar; |
Phlaphead | 0:3d93ff64fdee | 12 | char* heapPtr = (char*)malloc(sizeof(char)); |
Phlaphead | 0:3d93ff64fdee | 13 | int memFree = stackPtr - heapPtr; |
Phlaphead | 0:3d93ff64fdee | 14 | free(heapPtr); |
Phlaphead | 0:3d93ff64fdee | 15 | return memFree; |
Phlaphead | 0:3d93ff64fdee | 16 | } |