Barath Aron wrote: > What system implements a realloc() which does not work > if ptr is null pointer?
None, according to our findings [1]. > I looked into the fchdir.c ... new_dirs = (dirs != NULL ? (dir_info_t *) realloc (dirs, new_allocated * sizeof *dirs) : (dir_info_t *) malloc (new_allocated * sizeof *dirs)); > To me, it looks the ternary is unnecessary there, and only a single > realloc() is fine. This is correct. However, I prefer to keep the code as it is. Given that everyone knows what malloc() does, whereas - For realloc, there are three cases, - You have to look up the documentation to know exactly how realloc() behaves in each of the cases, the code is simpler to understand as is. > Or this is really a bug? It's not a bug. It's a question of style. Bruno [1] https://www.gnu.org/software/gnulib/manual/html_node/realloc.html