Re: patch for src/backend/main/main.c - Mailing list pgsql-patches

From Michael C. Thornburgh
Subject Re: patch for src/backend/main/main.c
Date
Msg-id 10101231731.aa10461@aldebaran.armory.com
Whole thread Raw
In response to patch for src/backend/main/main.c  ("Michael C. Thornburgh" <zenomt@armory.com>)
Responses Re: Re: patch for src/backend/main/main.c
Re: Re: patch for src/backend/main/main.c
List pgsql-patches
that certainly works and is much cleaner, but strdup
may not be as ubiquitous as malloc & strncpy.
someone more versed in portability issues than i am
should speak to that.

-michael thornburgh


> From: Tom Lane <tgl@sss.pgh.pa.us>
>
> "Michael C. Thornburgh" <zenomt@armory.com> writes:
> > +     len = strlen(pw->pw_name);
> > +     pw_name_persist = (char *) malloc(len+1);
> > +     if (pw_name_persist == (char *)NULL)
> > +     {
> > +         fprintf(stderr, "%s: can't malloc for username\n", argv[0]);
> > +         exit(1);
> > +     }
> > +     strncpy(pw_name_persist, pw->pw_name, len+1);
>
> This could be simplified to
>     pw_name_persist = strdup(pw->pw_name);
> no?
>
>             regards, tom lane

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: patch for src/backend/main/main.c
Next
From: Bruce Momjian
Date:
Subject: Re: Re: patch for src/backend/main/main.c