of course!
Joe Pruett
joey at tessi.UUCP
Fri Dec 8 12:09:31 AEST 1989
I know this is a GNU-ism, but local variable sized arrays seem
like the best of all worlds. For example:
isadir(path)
char *path;
{
char tpath[strlen(path) + 3];
strcpy(tpath, path);
strcat(tpath, "/.");
.
.
.
}
It is fairly quick, only uses as much memory as is necessary, and
the storage automatically goes away at the end of the function.
This is one of the best additions to C that I've seen. It's intuitive,
let's the compiler do the yucky work (alloca is a hack), and add's
a very useful feature.
Yes, 3 should be calculated instead of a constant, but I gotta
have something for people to complain about... :-)
More information about the Comp.unix.wizards
mailing list