You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.
I suggest the documentation makes explicitly clear what a functions expects from a struct we are passing it: does it expect the parameter and its contents to be valid after the function returns? will it take ownership?
Looking at the implementation is not always safe, because since it's not documented, a different implementation could be made that change my assumption. It's important this is documented at the level of Soletta API.
The documentation for sol_http_client_request() doesn't say whether it will be done with params (and its contents) after the function returns or not. On one hand the example just uses it in the stack, on the other hand there's a way to "copy strings when adding params", which make me confused what I can and can't do.
The documentation for sol_gpio_open() doesn't say whether it holds a reference to sol_gpio_config or not. Can I change the callback inside the config to something else? Does it copy the data pointer?
If there's a general way Soletta handles this (e.g. "function always use/copy what's needed before returning"), I still think is still relevant to make clear in the local function documentation. When not actively working on the API, we usually go for the documentation of the function we want to use and start from there. Having that information handy saves time.
Side note: by far, most of my questions when reading the documentation were like the above. I wasn't sure whether was OK to create some parameter struct on the stack or not.
The text was updated successfully, but these errors were encountered:
I suggest the documentation makes explicitly clear what a functions expects from a struct we are passing it: does it expect the parameter and its contents to be valid after the function returns? will it take ownership?
Looking at the implementation is not always safe, because since it's not documented, a different implementation could be made that change my assumption. It's important this is documented at the level of Soletta API.
Two examples I've stumbled upon recently:
The documentation for sol_http_client_request() doesn't say whether it will be done with params (and its contents) after the function returns or not. On one hand the example just uses it in the stack, on the other hand there's a way to "copy strings when adding params", which make me confused what I can and can't do.
The documentation for sol_gpio_open() doesn't say whether it holds a reference to sol_gpio_config or not. Can I change the callback inside the config to something else? Does it copy the data pointer?
If there's a general way Soletta handles this (e.g. "function always use/copy what's needed before returning"), I still think is still relevant to make clear in the local function documentation. When not actively working on the API, we usually go for the documentation of the function we want to use and start from there. Having that information handy saves time.
This is a spin off from my comment here: #2249 (comment)
The text was updated successfully, but these errors were encountered: