Show more

do not use dynamically allocated arrays on the stack. Do so on the heap only

if you allocate memory, you need to free it. strdup() allocates memory.... damnit!

String functions such as *printf() str*cmp() and others are meant to take string pointers. Under no circumstances should you use a function call, that returns NULL to indicate an error (like getenv()), as a parameter.

Unless you are working with an 8 bit compiler 0, '\0', and NULL are not synonyms.

When a C compiler gives you a warning, there is no reason to ignore it. If your code base is full of warnings how can you ever tell which poorly written piece of code is causing your current problem?

IBM XLC C compiler on AIX will treat a NULL as though it were an empty string "". There is a special circle of hell reserved for people that code counting on that behavior.

Show more
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.