Important reminder to anyone writing C APIs and for the ones learning to use it.
It is also major source of security and stability issues when not handled correctly.
As a helpful guide when writing complex C APIs:
- Explicitly define ownership of handled memory AND memory lifetime in API documentation
- Always sanitize and check for correctness input parameters to API
- Provide both at least one happy-case and multiple negative examples for using the API before any release
When writing them, try to ask yourself what you would ask Stackoverflow 🙂
This will help you understand usage patterns
Note: The easiest part is to create an API, the hardest is to change it in production.
Finally the C language it getting proper modern ‘face-lift’ that will potentially help and alleviate bunch of manual work and increase quality of written code.
Lets see if it will fizzle-out, or it will gain traction (looking at you, compiler vendors 😉 ).
Highly informative document for anyone switching between C and C++ and pitfalls of using same or similar approaches from one language into another.
To anyone interested in learning C++, with focus on usage in embedded environment.
Good comments especially valid to all related constraints and best practices for embedded implementation.
Fun use of GPT-3 to automate ‘handling’ of recruiter messaging 🙂