mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +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:
@ -229,8 +229,8 @@ pg_get_wal_record_info(PG_FUNCTION_ARGS)
|
||||
{
|
||||
#define PG_GET_WAL_RECORD_INFO_COLS 11
|
||||
Datum result;
|
||||
Datum values[PG_GET_WAL_RECORD_INFO_COLS];
|
||||
bool nulls[PG_GET_WAL_RECORD_INFO_COLS];
|
||||
Datum values[PG_GET_WAL_RECORD_INFO_COLS] = {0};
|
||||
bool nulls[PG_GET_WAL_RECORD_INFO_COLS] = {0};
|
||||
XLogRecPtr lsn;
|
||||
XLogRecPtr curr_lsn;
|
||||
XLogRecPtr first_record;
|
||||
@ -266,9 +266,6 @@ pg_get_wal_record_info(PG_FUNCTION_ARGS)
|
||||
errmsg("could not read WAL at %X/%X",
|
||||
LSN_FORMAT_ARGS(first_record))));
|
||||
|
||||
MemSet(values, 0, sizeof(values));
|
||||
MemSet(nulls, 0, sizeof(nulls));
|
||||
|
||||
GetWALRecordInfo(xlogreader, first_record, values, nulls,
|
||||
PG_GET_WAL_RECORD_INFO_COLS);
|
||||
|
||||
@ -334,8 +331,8 @@ GetWALRecordsInfo(FunctionCallInfo fcinfo, XLogRecPtr start_lsn,
|
||||
XLogRecPtr first_record;
|
||||
XLogReaderState *xlogreader;
|
||||
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
|
||||
Datum values[PG_GET_WAL_RECORDS_INFO_COLS];
|
||||
bool nulls[PG_GET_WAL_RECORDS_INFO_COLS];
|
||||
Datum values[PG_GET_WAL_RECORDS_INFO_COLS] = {0};
|
||||
bool nulls[PG_GET_WAL_RECORDS_INFO_COLS] = {0};
|
||||
|
||||
SetSingleFuncCall(fcinfo, 0);
|
||||
|
||||
@ -343,9 +340,6 @@ GetWALRecordsInfo(FunctionCallInfo fcinfo, XLogRecPtr start_lsn,
|
||||
|
||||
Assert(xlogreader);
|
||||
|
||||
MemSet(values, 0, sizeof(values));
|
||||
MemSet(nulls, 0, sizeof(nulls));
|
||||
|
||||
while (ReadNextXLogRecord(xlogreader, first_record) &&
|
||||
xlogreader->EndRecPtr <= end_lsn)
|
||||
{
|
||||
@ -556,17 +550,15 @@ GetWalStats(FunctionCallInfo fcinfo, XLogRecPtr start_lsn,
|
||||
#define PG_GET_WAL_STATS_COLS 9
|
||||
XLogRecPtr first_record;
|
||||
XLogReaderState *xlogreader;
|
||||
XLogStats stats;
|
||||
XLogStats stats = {0};
|
||||
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
|
||||
Datum values[PG_GET_WAL_STATS_COLS];
|
||||
bool nulls[PG_GET_WAL_STATS_COLS];
|
||||
Datum values[PG_GET_WAL_STATS_COLS] = {0};
|
||||
bool nulls[PG_GET_WAL_STATS_COLS] = {0};
|
||||
|
||||
SetSingleFuncCall(fcinfo, 0);
|
||||
|
||||
xlogreader = InitXLogReaderState(start_lsn, &first_record);
|
||||
|
||||
MemSet(&stats, 0, sizeof(stats));
|
||||
|
||||
while (ReadNextXLogRecord(xlogreader, first_record) &&
|
||||
xlogreader->EndRecPtr <= end_lsn)
|
||||
{
|
||||
@ -578,9 +570,6 @@ GetWalStats(FunctionCallInfo fcinfo, XLogRecPtr start_lsn,
|
||||
pfree(xlogreader->private_data);
|
||||
XLogReaderFree(xlogreader);
|
||||
|
||||
MemSet(values, 0, sizeof(values));
|
||||
MemSet(nulls, 0, sizeof(nulls));
|
||||
|
||||
GetXLogSummaryStats(&stats, rsinfo, values, nulls,
|
||||
PG_GET_WAL_STATS_COLS,
|
||||
stats_per_record);
|
||||
|
Reference in New Issue
Block a user