Re: New version of function mkdirhier()
Svante Signell, le Mon 16 Jan 2012 14:57:25 +0100, a écrit :
> Never mind: Attached is a dynamic-allocation version of mkdirhier.c
It loops good to me, except a few things.
> Is it possible to simplify the code somewhat, especially for the
> first version?
The pointers don't really need to be initialized to NULL, as they are
overwritten anyway. srcp is not needed either, as the src pointer is
never changed.
> if ((src = strdup(path)) == NULL)
> {
> errno = ENOMEM;
> return -1;
> }
> if ((dst = malloc(len + 1)) == NULL)
> {
missing free(src) here.
Samuel
Reply to: