This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add getmntent_r


And I missed a line in my dirty code example:

On Jun  5 14:42, Corinna Vinschen wrote:
>   What you want is more like this (untested):
> 
>   struct mntent *mnt = mount_table->getmntent (_my_tls.locals.iteration++);
>   if (!mnt)
>     return NULL;
>    int maxlen = strlen (mnt->mnt_fsname) + strlen (mnt->mnt_dir)
> 		+ strlen (mnt->mnt_type) + strlen (mnt->mnt_opts) + 4;
>    if (maxlen > buflen)
>      return NULL;
>    mntbuf->mnt_dir = stpcpy (mntbuf->mnt_fsname = buf, mnt->mnt_fsname);
>    mntbuf->mnt_type = stpcpy (mntbuf->mnt_dir, mnt->mnt_dir);
>    mntbuf->mnt_opts = stpcpy (mntbuf->mnt_type, mnt->mnt_type);

     stpcpy (mntbuf->mnt_opts, mnt->mnt_opts);

>    mntbuf->mnt_freq = mnt->mnt_freq;
>    mntbuf->mnt_passno = mnt->mnt_passno;
>    memcpy (buf, tmpbuf, buflen);
>    return mntbuf;


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]