Re: getopt() and strdup() - Mailing list pgsql-hackers

From Tom Lane
Subject Re: getopt() and strdup()
Date
Msg-id 23656.1349728409@sss.pgh.pa.us
Whole thread Raw
In response to getopt() and strdup()  (Bruce Momjian <bruce@momjian.us>)
Responses Re: getopt() and strdup()  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
Bruce Momjian <bruce@momjian.us> writes:
> A while ago I noticed that in some places we strdup/pg_strdup() optarg
> strings from getopt(), and in some places we don't.

> If we needed the strdup(), the missing cases should generate errors.  If
> we don't need them, the strdup() is unnecessary, and research confirms
> they are unnecessary.  Should we remove the extra strdup/pg_strdup()
> calls, for consistency.

What research?  Given the number of different ways argv[] is handled
on different platforms (cf ps_status.c), I am very unwilling to trust
that it's safe to hang onto an argv string for long without strdup'ing
it.

> I think we might have had old platforms that required it, but none are
> still supported today.

And what's your grounds for stating that?  All the alternatives in
ps_status.c are still live code AFAICS.

My feeling is it's more likely to be a good idea to be adding strdup's
than removing them.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: embedded list v3
Next
From: Robert Haas
Date:
Subject: Re: sortsupport for text