-
Notifications
You must be signed in to change notification settings - Fork 5
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
at_c: remove atclient_atstr/atbytes and use native char * C strings #284
Comments
@XavierChanth agrees that we should use |
@realvarx Would like your thoughts on this |
I believe that using On the other hand, I think it can still be useful in some contexts of less relevant internal functions, which the user should never need to call or use directly. |
After discussion with XC and AM, we would like to go through and eliminate atstr and go through with native char * C strings. I will be renaming the title and allocating SP to conduct the changes. Also adding to the breaking changes tracker |
Closed by #337 |
Would like to bring up discussion on getting rid of
atclient_atstr
For reasons:
How Functions That Have
atclient_atstr
As A Parameter Will ChangeThe initial reason why
atclient_atstr
was created, was because of the constant pattern of having 3 things bundled together: 1. a buffer, 2. a buffer size, and 3. length of the value inside of the buffer (the bytes we are concerned about).For functions that return strings, instead of populating an
atclient_atstr
, we should adopt the technique of passing a double pointer, where the function is in charge of allocating the memory of the string it wants to return.So instead of a function being called similarly to:
We would call it like:
The first way is inefficient because 256 bytes is always allocated, despite maybe only 100 (for example) is being actually useful.
The second way is more efficient because only enough memory is allocated as needed (100 for example, if an atkey string resulted in a length of 100).
How Structs That Use
atclient_atstr
As A Field/Variable Will ChangeThis is the
atclient_atkey
structThe struct would be changed to something like
Where in the
init
function, these will be set to NULLThere will also be
initializedfields
which will dictate which fields are initialized and are safe to be readThe text was updated successfully, but these errors were encountered: