Dear Hackers,

I have identified some OSS code which maybe can make use of C99 designated 
initialisers for nulls/values arrays.

~

Background:
There are lots of tuple operations where arrays of values and flags are being 
passed.
Typically these arrays are being previously initialised 0/false by memset.
By modifying code to use C99 designated initialiser syntax [1], most of these 
memsets can become redundant.
Actually, this mechanism is already being used in some of the existing OSS 
code. This patch/proposal just propagates the same idea to all other similar 
places I could find.

~

Result:
Less code. Removes ~200 unnecessary memsets.
More consistent initialisation.

~

Typical Example:
Before:
        Datum           values[Natts_pg_attribute];
        bool            nulls[Natts_pg_attribute];
        ...
        memset(values, 0, sizeof(values));
        memset(nulls, false, sizeof(nulls));
After:
        Datum           values[Natts_pg_attribute] = {0};
        bool            nulls[Natts_pg_attribute] = {0};


---
[1] REF C99 [$6.7.8/21] If there are fewer initializers in a brace-enclosed 
list than there are elements or members of an aggregate, 
or fewer characters in a string literal used to initialize an array of known 
size than there are elements in the array, 
the remainder of the aggregate shall be initialized implicitly the same as 
objects that have static storage duration

~

Please refer to the attached patch.

Kind Regards,

---
Peter Smith
Fujitsu Australia




Attachment: init_nulls.patch
Description: init_nulls.patch

Reply via email to