Re: New version of function mkdirhier()
On Fri, 2012-01-13 at 03:05 +0100, Samuel Thibault wrote:
> Svante Signell, le Thu 12 Jan 2012 18:07:46 +0100, a écrit :
> > int
> > mkdirhier(char *path)
> This will alloc 0*strlen(src) bytes. Probably not what you want. Why
> using calloc() actually? malloc should be just fine, setting dst = 0;
> just after that. You also need to use strlen(src)+1, else you don't have
> room for the 0-termination.
> > if (len > 0)
> You don't need this test: you have already tested the 0 case above.
> > /* Create dir after last '/' or no '/' in path */
> > if ((dirp = strchr(src, '\0')) != NULL)
> Why using strchr to look for \0? Simply use strlen to get the length
> until the string termination.
You mean len = strlen(src); ?