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 @@ -217,30 +217,31 @@ String EspClass::getSketchMD5()
217
217
const esp_partition_t *running = esp_ota_get_running_partition ();
218
218
if (!running) {
219
219
log_e (" Partition could not be found" );
220
-
221
220
return String ();
222
221
}
222
+
223
223
const size_t bufSize = SPI_FLASH_SEC_SIZE;
224
- std::unique_ptr<uint8_t []> buf (new uint8_t [bufSize]);
225
- uint32_t offset = 0 ;
226
- if (!buf.get ()) {
224
+ uint8_t *pb = (uint8_t *)malloc (bufSize);
225
+ if (!pb) {
227
226
log_e (" Not enough memory to allocate buffer" );
228
-
229
227
return String ();
230
228
}
229
+ uint32_t offset = 0 ;
230
+
231
231
MD5Builder md5;
232
232
md5.begin ();
233
- while ( lengthLeft > 0 ) {
233
+ while (lengthLeft > 0 ) {
234
234
size_t readBytes = (lengthLeft < bufSize) ? lengthLeft : bufSize;
235
- if (!ESP.flashRead (running->address + offset, reinterpret_cast <uint32_t *>(buf.get ()), (readBytes + 3 ) & ~3 )) {
235
+ if (!ESP.flashRead (running->address + offset, (uint32_t *)pb, (readBytes + 3 ) & ~3 )) {
236
+ free (pb);
236
237
log_e (" Could not read buffer from flash" );
237
-
238
238
return String ();
239
239
}
240
- md5.add (buf. get () , readBytes);
240
+ md5.add (pb , readBytes);
241
241
lengthLeft -= readBytes;
242
242
offset += readBytes;
243
243
}
244
+ free (pb);
244
245
md5.calculate ();
245
246
result = md5.toString ();
246
247
return result;
You can’t perform that action at this time.
0 commit comments