Re: Idea: closing the loop for "pg_ctl reload" - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Idea: closing the loop for "pg_ctl reload"
Date
Msg-id 6225.1425318280@sss.pgh.pa.us
Whole thread Raw
In response to Re: Idea: closing the loop for "pg_ctl reload"  (Jan de Visser <jan@de-visser.net>)
Responses Re: Idea: closing the loop for "pg_ctl reload"  (Jan de Visser <jan@de-visser.net>)
List pgsql-hackers
Jan de Visser <jan@de-visser.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



pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: INSERT ... ON CONFLICT {UPDATE | IGNORE} 2.0
Next
From: Andres Freund
Date:
Subject: Re: Merge compact/non compact commits, make aborts dynamically sized