News for hackers. Stuff that matters.
Re:C Programming Guidelines by btrask on Wednesday September 02, 2015 @07:11PM (#10162526)
If `foo` doesn't own `buf`, it should be declared `char * const` (or `char const * const`). If `foo` takes owner ship of `buf` (and is intended to free it), it should take a pointer to the pointer to clear it for the caller. This is one way to write it:

    void foo(char **const bufptr) {
        ...
        free(*bufptr); *bufptr = NULL;
    }
You can dereference `bufptr` at the top of the function to make the code more readable. This is how (almost) every object freeing function works in my project.

There are no comments on this comment yet.