Don't calculate len too early.

This commit is contained in:
Pawel Jakub Dawidek 2011-03-26 07:17:24 +00:00
parent 32981eb31b
commit 6d0d40f668

View file

@ -207,10 +207,10 @@ see
.Pp
Sample code which searches a directory for entry ``name'' is:
.Bd -literal -offset indent
len = strlen(name);
dirp = opendir(".");
if (dirp == NULL)
return (ERROR);
len = strlen(name);
while ((dp = readdir(dirp)) != NULL) {
if (dp->d_namlen == len && strcmp(dp->d_name, name) == 0) {
(void)closedir(dirp);