of course!

Martin Weitzel martin at mwtech.UUCP
Thu Nov 23 23:39:39 AEST 1989


In article <1051 at root44.co.uk> gwc at root.co.uk (Geoff Clare) writes:
[first part deleted]
>The fact that the strcat() may write past the end of dir[] is more of
>a problem.  Another is that PATH_MAX might not be defined (it should
>always be obtained via pathconf() in portable applications).  Anyway,
>using a maximum length array is rather wasteful - malloc(strlen(path)+3)
>would be much better all round.

But then you should not forget to check the result (in a portable approach
you cannot assume these huge amount of memory, some people are used to
have - or ULIMIT may be set low in the environment, the program runs).
And of course: Don't forget to do a 'free'. And what should the programm
do, if there is no memory from malloc() - abort? The one who uses the
directory-check function might not like this ...

Ehhm, what was the original question? Something faster than 'access()'.
Seems to be the time to stop this now ....

MW



More information about the Comp.unix.wizards mailing list