Re: Idea: closing the loop for "pg_ctl reload"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jan de Visser <jan(at)de-visser(dot)net>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Idea: closing the loop for "pg_ctl reload"
Date: 2015-03-02 17:44:40
Message-ID: 6225.1425318280@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jan de Visser <jan(at)de-visser(dot)net> writes:
> On March 2, 2015 09:50:49 AM Tom Lane wrote:
>> However, you could and should use pg_malloc0, which takes care of that
>> for you...

> I am (using pg_malloc, that is). So, just to be sure: pg_malloc memsets the
> block to 0, right?

No, it doesn't, but pg_malloc0 does. Consult the code if you're confused:
src/common/fe_memutils.c

> My question was more along the lines if memsetting to 0 to ensure that pointer
> fields are NULL and int/long fields are 0.

Yes, we do assume that widely, and so does a heck of a lot of other code.
In principle the C standard doesn't require that a NULL pointer be
all-zero-bits, only that casting "0" to a pointer yield a NULL pointer.
But certainly there are no modern implementations that don't represent
NULL as 0. Anybody who tried to do it differently would soon find that
hardly any real-world C code would run on their platform.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2015-03-02 17:45:18 Re: Merge compact/non compact commits, make aborts dynamically sized
Previous Message Heikki Linnakangas 2015-03-02 17:41:52 Re: INSERT ... ON CONFLICT {UPDATE | IGNORE} 2.0