aboutsummaryrefslogtreecommitdiff
path: root/contributing.md
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-12-18 13:36:52 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-12-18 13:36:52 +0100
commit0e800c6857122436e7a766c6934991aa1d8d31ff (patch)
treece5eb98a3b93b40b9535613b84eff3a7a4b1854a /contributing.md
parent3c7373eba71ccf5f16069d540c9f66e297895b1a (diff)
parent81404db80bbf9463c3d535ae389e7fbb753a902c (diff)
Merge branch 'master' into loek/savemgrloek/savemgr
Diffstat (limited to 'contributing.md')
-rw-r--r--contributing.md26
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