debevv / nanoMODBUS

A compact MODBUS RTU/TCP C library for embedded/microcontrollers
MIT License
234 stars 47 forks source link

Document that the platform configuration and callbacks can be discarded after initialization #9

Closed jonathangjertsen closed 2 years ago

jonathangjertsen commented 2 years ago

nmbs_client_create accepts a const nmbs_platform_conf* platform_conf with configuration. Without reading the source code, it is not clear whether or not the object pointed to by platform_conf can be declared on the stack, or if it needs to be kept alive for the duration of the program (as would be the case if the implementation simply kept a pointer to the configuration instead of copying it by value). This PR adds an assurance that it is OK to discard the platform configuration after calling nmbs_client_create. Same idea for nmbs_server_create.

debevv commented 2 years ago

I just would add on the @param platform_conf line It may be discarded after calling this method