File tree 1 file changed +10
-9
lines changed
1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -225,30 +225,31 @@ String EspClass::getSketchMD5()
225
225
const esp_partition_t *running = esp_ota_get_running_partition ();
226
226
if (!running) {
227
227
log_e (" Partition could not be found" );
228
-
229
228
return String ();
230
229
}
230
+
231
231
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) {
235
234
log_e (" Not enough memory to allocate buffer" );
236
-
237
235
return String ();
238
236
}
237
+ uint32_t offset = 0 ;
238
+
239
239
MD5Builder md5;
240
240
md5.begin ();
241
- while ( lengthLeft > 0 ) {
241
+ while (lengthLeft > 0 ) {
242
242
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);
244
245
log_e (" Could not read buffer from flash" );
245
-
246
246
return String ();
247
247
}
248
- md5.add (buf. get () , readBytes);
248
+ md5.add (pb , readBytes);
249
249
lengthLeft -= readBytes;
250
250
offset += readBytes;
251
251
}
252
+ free (pb);
252
253
md5.calculate ();
253
254
result = md5.toString ();
254
255
return result;
You can’t perform that action at this time.
0 commit comments