Re: fchdir() question

2018-08-08 Thread Bruno Haible
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) : (di

Re: fchdir() question

2018-08-08 Thread Paul Eggert
Barath Aron wrote: What system implements a realloc() which does not work if ptr is null pointer? I think the main problem area here is realloc (NULL, 0), where POSIX does not completely specify the behavior but GNU does. Only very ancient systems have problems with realloc (NULL, x) when x i

fchdir() question

2018-08-08 Thread Barath Aron
Hello, I looked into the fchdir.c (I was curious how it is implemented), and I noticed something interesting. This is not an actual bug, but I wonder why. The ensure_dirs_slot() function allocates some memory, and it uses malloc() if no memory was allocated before, and uses realloc() otherwise