diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-17 20:36:11 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-17 20:36:11 +0100 |
commit | 50bf1a39668075f206b247cc091a1c542f49a01e (patch) | |
tree | d37345262f7bd119b7dacceb55b23ca7c4a584fc /contributing.md | |
parent | 917103511c6dcb9aa258cc4dc1aeff9e27593d19 (diff) | |
parent | 81404db80bbf9463c3d535ae389e7fbb753a902c (diff) |
Merge branch 'master' of https://github.com/lonkaars/crepe into wouter/button-improvement
Diffstat (limited to 'contributing.md')
-rw-r--r-- | contributing.md | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/contributing.md b/contributing.md index 0faed2b..5555892 100644 --- a/contributing.md +++ b/contributing.md @@ -827,6 +827,32 @@ that you can click on to open them. int bar = foo[0]; ``` </td></tr></table></details> +- <details><summary> + Always explicitly check against <code>NULL</code> (for C APIs) or + <code>nullptr</code> (for C++ APIs) when checking if a pointer is valid + </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td> + + ```cpp + string foo = "Hello world"; + if (foo.c_str() == nullptr) + // ... + + void * bar = malloc(); + if (bar == NULL) + // ... + ``` + </td><td> + + ```cpp + string foo = "Hello world"; + if (!foo.c_str()) + // ... + + void * bar = malloc(); + if (!bar) + // ... + ``` + </td></tr></table></details> ## CMakeLists-specific |