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


On Jun  5 16:39, Corinna Vinschen wrote:
> And I missed a line in my dirty code example:

And I missed to add a + 1 to the pointers returned from stpcpy.  Sigh.
Let's restart:

  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_fsname = buf;
  mntbuf->mnt_dir = stpcpy (mntbuf->mnt_fsname, mnt->mnt_fsname) + 1;
  mntbuf->mnt_type = stpcpy (mntbuf->mnt_dir, mnt->mnt_dir) + 1;
  mntbuf->mnt_opts = stpcpy (mntbuf->mnt_type, mnt->mnt_type) + 1;
  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;

Sorry about that.  Hopefully you get the idea, regardless.


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]