Skip to content

Commit ccaa7b8

Browse files
committed
Allocate buffer on heap
1 parent befe931 commit ccaa7b8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

examples/PortentaH7Logger/PortentaH7Logger.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ void performUpdate() {
9797
unsigned long totalBytesToMove = bytesWritten - lastUpdateBytes;
9898
Serial.print("New update bytes: "); Serial.println(totalBytesToMove);
9999

100-
uint8_t buffer[totalBytesToMove];
100+
uint8_t* buffer = new uint8_t[totalBytesToMove];
101+
101102
size_t bytesRead = logFile.read(buffer, totalBytesToMove);
102103
size_t bytesMoved = backupFile.write(buffer, bytesRead); // Only write the bytes that haven't been backed up yet
103104

@@ -115,6 +116,7 @@ void performUpdate() {
115116

116117
digitalWrite(USB_MOUNTED_LED, HIGH);
117118
backingUP = false;
119+
delete[] buffer;
118120
}
119121

120122

0 commit comments

Comments
 (0)