mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[GH-ISSUE #1000] Feature Idea: self allocated (statically) declared parameters #852
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#852
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Bilgus on GitHub (Jan 31, 2020).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1000
Parameters are alloc'd and copied from the source variable
it would be nice to have the option to supply the buffer myself
especially considering the eeprom code I'm using already makes a copy of the structure from flash
the changes I made are from the dev branch
WiFiManager.h:
class WiFiManagerParameter
public:
WiFiManagerParameter(const char *id, const char *label, char *buffer, int length); WiFiManagerParameter(const char *id, const char *label, char *buffer, int length, const char *custom); WiFiManagerParameter(const char *id, const char *label, char *buffer, int length, const char *custom, int labelPlacement);protected:
void init_buf(const char *id, const char *label, char *buffer, int length, const char *custom, int labelPlacement);private:
bool _allocd;WifiManager.cpp
WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *label, char *buffer, int length) { init_buf(id, label, buffer, length, "", WFM_LABEL_BEFORE); }WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *label, char *buffer, int length, const char *custom) { init_buf(id, label, buffer, length, custom, WFM_LABEL_BEFORE); }WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *label, char *buffer, int length, const char *custom, int labelPlacement) { init_buf(id, label, buffer, length, custom, labelPlacement); }void WiFiManagerParameter::init(const char *id, const char *label, const char *defaultValue, int length, const char *custom, int labelPlacement) { _id = id; _label = label; _labelPlacement = labelPlacement; _customHTML = custom; setValue(defaultValue,length); _allocd = true; }void WiFiManagerParameter::init_buf(const char *id, const char *label, char *buffer, int length, const char *custom, int labelPlacement) { _id = id; _label = label; _labelPlacement = labelPlacement; _customHTML = custom; _length = length; _value = buffer; _allocd = false; if (length > 0) buffer[length-1] = '\0'; else _value = NULL; }WiFiManagerParameter::~WiFiManagerParameter() { if (_value != NULL && _allocd) { delete[] _value; } _length=0; // setting length 0, ideally the entire parameter should be removed, or added to wifimanager scope so it follows }