From 9282e0ab8be8ad09a7fb1018f5139b6bc0c62f8d Mon Sep 17 00:00:00 2001 From: ProgmaticProgrammer <51181822+ProgmaticProgrammer@users.noreply.github.com> Date: Fri, 3 Apr 2020 12:38:56 +0800 Subject: [PATCH] A tempText memleak --- .../EduBP_MKII_Production_Test/EduBP_MKII_Production_Test.ino | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/shared/examples/09.EducationalBP_MKII/EduBP_MKII_Production_Test/EduBP_MKII_Production_Test.ino b/build/shared/examples/09.EducationalBP_MKII/EduBP_MKII_Production_Test/EduBP_MKII_Production_Test.ino index 1d7365f2c70..dfda77f6b4e 100644 --- a/build/shared/examples/09.EducationalBP_MKII/EduBP_MKII_Production_Test/EduBP_MKII_Production_Test.ino +++ b/build/shared/examples/09.EducationalBP_MKII/EduBP_MKII_Production_Test/EduBP_MKII_Production_Test.ino @@ -475,7 +475,7 @@ void loop() float temp = tmp006.readObjTempC(); char* tempText; char ii; - tempText = (char*) malloc(10); + tempText = (char*) malloc(10);//WHY NOT USE stack memory char tempText[10]? for (ii=0;ii<10;ii++) tempText[ii] = 0; tempText = ftoa(tempText, temp, 4); @@ -484,6 +484,8 @@ void loop() myScreen.gText(60,20, "*C", colour); myScreen.gText(0,40, " RGB LED Test", blueColour); + free(tempText);//DO NOT use tempText any more. + //TEST OPT3001 LIGHT SENSOR //To be enabled once OPT3001 is added to future Edu BP MK II Rev. // Serial.println("Cover the light sensor to test the OPT3001.");