Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
template.c
00001 int stackUsage_Template() 00002 { 00003 char* stackArr = NULL; 00004 int i = 0; 00005 int stackUsageCounter = 0; 00006 bool detectChange = false; 00007 char borderArr[BORDER_ARRAY_SIZE]; //Used to mark the border of a stack frame. 00008 for(i=0; i < BORDER_ARRAY_SIZE; ++i) 00009 { 00010 borderArr[i] = INIT_VALUE; 00011 } 00012 stackArr = paintStack(); 00013 Template_Func(); 00014 // The size of the second array is: 3*STACK_UNIT_SIZE. 00015 // so we need to run over the array to detect the first changed byte. 00016 // once we detect this byte, we can calculate the maximum stack usage. 00017 for (i = 0 ; i < STACK_UNIT_NUM*STACK_UNIT_SIZE && !detectChange; ++i) 00018 { 00019 if(stackArr[i] != ((memPattern[i%PATTERN_SIZE]) ^ (i%MAX_CHAR_VALUE))) 00020 { 00021 detectChange = true; 00022 } 00023 } 00024 stackUsageCounter = STACK_UNIT_NUM*STACK_UNIT_SIZE - i; 00025 stackArr = stackArr + STACK_UNIT_NUM * STACK_UNIT_SIZE; 00026 for (; stackArr != borderArr; ++stackArr) 00027 { 00028 ++stackUsageCounter; 00029 } 00030 return stackUsageCounter; 00031 }
Generated on Mon Aug 29 2022 19:53:42 by
