Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions firmware/patternflow/features/show/core_show.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,20 @@ inline void clearPlaylist() { clearRuntimePlaylist(); }
inline void savePrefs() {
Preferences prefs;
if (!prefs.begin("pfshow", false)) return;
char blob[PLAYLIST_MAX * SLUG_BYTES + 8] = {};
// A full 64-slug list is ~2.5 KB — keep it off the loop-task stack.
// Short-lived heap (not static): tree rule is no permanent buffers over 1 KB.
constexpr size_t kBlobBytes = PLAYLIST_MAX * SLUG_BYTES + 8;
char* blob = static_cast<char*>(malloc(kBlobBytes));
if (!blob) {
prefs.end();
return;
}
blob[0] = '\0';
size_t n = 0;
for (uint8_t i = 0; i < storedCount; i++) {
if (i && n + 1 < sizeof(blob)) blob[n++] = ',';
if (i && n + 1 < kBlobBytes) blob[n++] = ',';
size_t len = strlen(stored[i]);
if (n + len >= sizeof(blob)) break;
if (n + len >= kBlobBytes) break;
memcpy(blob + n, stored[i], len);
n += len;
}
Expand All @@ -464,6 +472,7 @@ inline void savePrefs() {
prefs.putUChar("var_cue", varianceCue);
prefs.putUChar("var_p", varianceParam);
prefs.end();
free(blob);
}

inline void loadPrefs() {
Expand Down
Loading