Re: Problem in Strdup()
- From: Tim Rentsch <txr@xxxxxxxxxxxxxxxxxxx>
- Date: 30 Aug 2005 12:42:29 -0700
pete <pfiland@xxxxxxxxxxxxxx> writes:
> Tim Rentsch wrote:
> >
> > pete <pfiland@xxxxxxxxxxxxxx> writes:
> >
> > > Tim Rentsch wrote:
> > > >
> > > > Keith Thompson <kst-u@xxxxxxx> writes:
> > >
> > > > > How about this?
> > > > >
> > > > > char *dupstr(const char *src)
> > > > > {
> > > > > char *p = malloc(strlen(src) + 1);
> > > > > if (p != NULL) {
> > > > > strcpy(p, src);
> > > > > }
> > > > > return p;
> > > > > }
> > > >
> > > > char *dupstr(const char *src)
> > > > {
> > > > char *p = malloc(strlen(src) + 1);
> > > >
> > > > return p ? strcpy(p,src) : 0;
> > > > }
> > >
> > > I like Keith's better.
> >
> > That's all well and good, but what qualities allow
> > the first to be judged better than the second?
> > What is your metric?
>
> Keith's is simpler.
Is this some objective metric that you're applying,
or just your personal subjective metric? Most of
the metrics I'm used to would rank the second
definition as simpler.
.
- References:
- Problem in Strdup()
- From: priya
- Re: Problem in Strdup()
- From: manoj1978
- Re: Problem in Strdup()
- From: James Daughtry
- Re: Problem in Strdup()
- From: CBFalconer
- Re: Problem in Strdup()
- From: Gary E. Ansok
- Re: Problem in Strdup()
- From: Keith Thompson
- Re: Problem in Strdup()
- From: Tim Rentsch
- Re: Problem in Strdup()
- From: pete
- Re: Problem in Strdup()
- From: Tim Rentsch
- Re: Problem in Strdup()
- From: pete
- Problem in Strdup()
- Prev by Date: Re: while (1) vs. for ( ;; )
- Next by Date: Re: low-level question
- Previous by thread: Re: Problem in Strdup()
- Next by thread: Re: Problem in Strdup()
- Index(es):
Relevant Pages
|