[esp32][libretiny] Reuse preference buffer to avoid heap churn

This commit is contained in:
J. Nick Koston
2026-01-03 21:16:25 -10:00
parent 5d384c77c5
commit 0f6b9818e4
2 changed files with 8 additions and 4 deletions

View File

@@ -23,9 +23,11 @@ struct NVSData {
size_t len;
void set_data(const uint8_t *src, size_t size) {
this->data = std::make_unique<uint8_t[]>(size);
if (this->len != size) {
this->data = std::make_unique<uint8_t[]>(size);
this->len = size;
}
memcpy(this->data.get(), src, size);
this->len = size;
}
};

View File

@@ -22,9 +22,11 @@ struct NVSData {
size_t len;
void set_data(const uint8_t *src, size_t size) {
this->data = std::make_unique<uint8_t[]>(size);
if (this->len != size) {
this->data = std::make_unique<uint8_t[]>(size);
this->len = size;
}
memcpy(this->data.get(), src, size);
this->len = size;
}
};