Re: Compiler warnings with stringRelOpts (was WIP: Fast GiST index build)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Subject: Re: Compiler warnings with stringRelOpts (was WIP: Fast GiST index build)
Date: 2011-08-09 16:16:16
Message-ID: 27894.1312906576@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> writes:
> On 09.08.2011 18:04, Alvaro Herrera wrote:
>> I think I vaguely remember that the reason for doing it this way is that
>> the copy into the relcache worked, i.e. if the originals went away,
>> there was no dangling pointer. Did you test this?

> These strings are never freed, so I don't think it's possible to end up
> with a dangling pointer.

Well, in that case the relevant question is whether we need to worry
about memory leaks due to multiple copies.

Personally I'm wondering why the function is strdup'ing the default
value at all. In practice, wouldn't it practically always be a compile
time constant string? Why create possible issues by designing the code
for a different use-case? In particular, why not declare the default
value as "const char *" and specify that it's caller's responsibility
that it live forever if it's not just a constant string?

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-08-09 16:22:46 Re: plperl crash with Debian 6 (64 bit), pl/perlu, libwww and https
Previous Message Tom Lane 2011-08-09 16:07:14 Re: Enforcing that all WAL has been replayed after restoring from backup