1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-15 19:21:59 +03:00

Replace many MemSet calls with struct initialization

This replaces all MemSet() calls with struct initialization where that
is easily and obviously possible.  (For example, some cases have to
worry about padding bits, so I left those.)

(The same could be done with appropriate memset() calls, but this
patch is part of an effort to phase out MemSet(), so it doesn't touch
memset() calls.)

Reviewed-by: Ranier Vilela <ranier.vf@gmail.com>
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://www.postgresql.org/message-id/9847b13c-b785-f4e2-75c3-12ec77a3b05c@enterprisedb.com
This commit is contained in:
Peter Eisentraut
2022-07-16 08:42:15 +02:00
parent c94ae9d827
commit 9fd45870c1
51 changed files with 200 additions and 468 deletions

View File

@ -4924,7 +4924,7 @@ pg_timezone_abbrevs(PG_FUNCTION_ARGS)
Datum result;
HeapTuple tuple;
Datum values[3];
bool nulls[3];
bool nulls[3] = {0};
const datetkn *tp;
char buffer[TOKMAXLEN + 1];
int gmtoffset;
@ -5011,8 +5011,6 @@ pg_timezone_abbrevs(PG_FUNCTION_ARGS)
break;
}
MemSet(nulls, 0, sizeof(nulls));
/*
* Convert name to text, using upcasing conversion that is the inverse of
* what ParseDateTime() uses.
@ -5051,7 +5049,7 @@ pg_timezone_names(PG_FUNCTION_ARGS)
pg_tzenum *tzenum;
pg_tz *tz;
Datum values[4];
bool nulls[4];
bool nulls[4] = {0};
int tzoff;
struct pg_tm tm;
fsec_t fsec;
@ -5088,8 +5086,6 @@ pg_timezone_names(PG_FUNCTION_ARGS)
if (tzn && strlen(tzn) > 31)
continue;
MemSet(nulls, 0, sizeof(nulls));
values[0] = CStringGetTextDatum(pg_get_timezone_name(tz));
values[1] = CStringGetTextDatum(tzn ? tzn : "");