Is free(NULL) OK?

Hal Murray halmurray at sonic.net
Sun Jan 12 06:43:47 UTC 2025


The Linux man page says 
       If ptr is NULL, no operation is performed.

I'd expect a wrapper if there really was a problem.

This code is in ntpd/ntp_config.c
        if (NULL == s) {                        /* free() hates NULL */
                s = estrdup("");
        }

Any reason not to nuke that chunk of code?


-- 
These are my opinions.  I hate spam.





More information about the devel mailing list