File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -225,30 +225,31 @@ String EspClass::getSketchMD5()
225225 const esp_partition_t *running = esp_ota_get_running_partition ();
226226 if (!running) {
227227 log_e (" Partition could not be found" );
228-
229228 return String ();
230229 }
230+
231231 const size_t bufSize = SPI_FLASH_SEC_SIZE;
232- std::unique_ptr<uint8_t []> buf (new uint8_t [bufSize]);
233- uint32_t offset = 0 ;
234- if (!buf.get ()) {
232+ uint8_t *pb = (uint8_t *)malloc (bufSize);
233+ if (!pb) {
235234 log_e (" Not enough memory to allocate buffer" );
236-
237235 return String ();
238236 }
237+ uint32_t offset = 0 ;
238+
239239 MD5Builder md5;
240240 md5.begin ();
241- while ( lengthLeft > 0 ) {
241+ while (lengthLeft > 0 ) {
242242 size_t readBytes = (lengthLeft < bufSize) ? lengthLeft : bufSize;
243- if (!ESP.flashRead (running->address + offset, reinterpret_cast <uint32_t *>(buf.get ()), (readBytes + 3 ) & ~3 )) {
243+ if (!ESP.flashRead (running->address + offset, (uint32_t *)pb, (readBytes + 3 ) & ~3 )) {
244+ free (pb);
244245 log_e (" Could not read buffer from flash" );
245-
246246 return String ();
247247 }
248- md5.add (buf. get () , readBytes);
248+ md5.add (pb , readBytes);
249249 lengthLeft -= readBytes;
250250 offset += readBytes;
251251 }
252+ free (pb);
252253 md5.calculate ();
253254 result = md5.toString ();
254255 return result;
You can’t perform that action at this time.
0 commit comments