diff options
| author | Nicolas Dato <nicolas.dato@gmail.com> | 2025-03-26 15:14:00 -0300 |
|---|---|---|
| committer | Nicolas Dato <nicolas.dato@gmail.com> | 2025-03-26 15:14:00 -0300 |
| commit | 63d776b9d6afd037bd115dc365b2dffd5e699991 (patch) | |
| tree | e201ba5f23ef986ed8b24898a0271f983f3bbcb5 /zola/content/articles/safer-pointers.md | |
| parent | 88d3d8ee6a550476cff898b5456d356db4eebaa3 (diff) | |
| download | ndato.com-63d776b9d6afd037bd115dc365b2dffd5e699991.tar.gz | |
new article, using typedef or not
Diffstat (limited to 'zola/content/articles/safer-pointers.md')
| -rw-r--r-- | zola/content/articles/safer-pointers.md | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/zola/content/articles/safer-pointers.md b/zola/content/articles/safer-pointers.md index 1a1b55e..d6fd418 100644 --- a/zola/content/articles/safer-pointers.md +++ b/zola/content/articles/safer-pointers.md @@ -14,10 +14,10 @@ Tags=["C", "Patterns", "Pointers"] Pointers are an important feature of C, but at the same time they are prone to error. To reduce errors, and make them safer to use, I propose the following 4 tips: -1. Encapsulating the *malloc()* and *free()* functions +1. Encapsulating the *malloc()* and *free()* functions. 2. Using *calloc()* in the new alloc function, and making the structure "fail-safe" when everything is zero. -3. Making the new *free* function set the freed pointer to *NULL* -4. Every time a pointer is passed to another function, deciding who *owns* the pointer +3. Making the new *free* function set the freed pointer to *NULL*. +4. Every time a pointer is passed to another function, deciding who *owns* the pointer. ### Example |