-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JsonDocument dynamic allocation problem #1480
Comments
Sorry,
(only changing Then, Many thanks Leonardo |
Hi Leonardo, Thank you very much for opening this issue.
Now, I don't understand why anyone would want to do that since DynamicJsonDocument makeJsonDocument() {
DynamicJsonDocument doc(1024);
// ...
return doc;
}
Best regards, |
Many Thanks! I admit that I did not know Copy-Elision, then your suggestion is good and efficient. I also have attempted to write a function like:
but was not accepted by compiler ... Leonardo |
Yes, that's expected. |
One question, does that mean that DynamicJsonDocument has built-in smart shared pointer functionality? In other words:
would not bring any benefit over
Thank you for the clarification! |
@smuellener, in a sense, it's more like |
ArduinoJson 6.17.3 includes the protected destructor. |
Hi,
the title not refers to
DynamicJsonDocument
, but it refers precisely to dinamic allocation of aJsonDocument
withnew
!My environment is:
Platform: ESP32 TTGO
IDE: Arduino IDE 1.8.13
The simple code below compile well, but crash at
delete
:(this is a minimal example for a scenario where I allocate dinamically a
JsonDocument
into a function, return a pointer, and only after use, I call destructor in a different scope withdelete
in a different scope)I appreciate any help to understand my error
Many thanks in advance
Leonardo
The text was updated successfully, but these errors were encountered: