[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: why is this code here?

On Fri, Dec 10, 1999 at 01:39:07PM -0800, Sean 'Shaleh' Perry was heard to say:
> in dbootstrap/choose_medium.c:choose_NFS_server()
> for (;;) {
>     /* keep user entry between calls to choose_NFS_server */
>     if (!preventry) preventry=strdup(""); <<-- why??????
>     nfsmountpath=inputBox(_("Please choose the NFS server and the mount path of
> the NFS filesystem that contains the Debian archive.\nEnter them in this way: 
> server:/ftp/debian"),_("Choose Debian NFS filesystem"),preventry);
>     if (! nfsmountpath) return 1;
>     free(preventry);
>     preventry=nfsmountpath;
> .....
> }
> preventry is set to NULL at the top, strdup("") just sets it to NULL again. 
> What am I missing????

  Huh?  Unless the semantics of C strings have changed underneath me, strdup("")
sets it to *a pointer to* a NULL byte.  This is important, since otherwise
you'll segfault when you try to access strdup..assuming that inputBox doesn't
treat NULL strings as "".


  Believe in the Great God Om or be stricken with thunderbolts?
  Is that the way it always has to be?

             -- Terry Pratchett, _Small Gods_

Reply to: