4 ms·
IMO you should assert it's not null. There should never be a circumstance where you pass a null pointer to a function.
by cakealert 1y ago
IMO you should assert it's not null. There should never be a circumstance where you pass a null pointer to a function.
- kazinator 1y agoISO C allows: free(NULL); // convenient no-op, does nothing fflush(NULL); // flush all streams; done implicitly on normal exit time(NULL); // don't store time_t into a location, just return it strtol(text, NULL, 10); // not interested in pointer to first garbage char setbuf(stream, NULL); // allocate a buffer for stream realloc(NULL, size); // behave like malloc(size) and others. More examples in POSIX and other APIs: sigprocmask(SIG_UNBLOCK, these_sigs, NULL); // not interested in previous signal mask CreateEventA(NULL, FALSE, FALSE, NULL); // no security attributes, no name Reality just ran over your opinion, oops!
- cakealert 1y agoI'm sorry. Are you claiming the people who designed those functions made good choices? They altered the behavior of the function considerably for a single input value that is more likely to be a bug than not.
- kazinator 1y agoYes. I will probably continue to make similar choices of the future.