mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +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:
@ -75,7 +75,7 @@ pg_visibility_map(PG_FUNCTION_ARGS)
|
||||
Buffer vmbuffer = InvalidBuffer;
|
||||
TupleDesc tupdesc;
|
||||
Datum values[2];
|
||||
bool nulls[2];
|
||||
bool nulls[2] = {0};
|
||||
|
||||
rel = relation_open(relid, AccessShareLock);
|
||||
|
||||
@ -88,7 +88,6 @@ pg_visibility_map(PG_FUNCTION_ARGS)
|
||||
errmsg("invalid block number")));
|
||||
|
||||
tupdesc = pg_visibility_tupdesc(false, false);
|
||||
MemSet(nulls, 0, sizeof(nulls));
|
||||
|
||||
mapbits = (int32) visibilitymap_get_status(rel, blkno, &vmbuffer);
|
||||
if (vmbuffer != InvalidBuffer)
|
||||
@ -117,7 +116,7 @@ pg_visibility(PG_FUNCTION_ARGS)
|
||||
Page page;
|
||||
TupleDesc tupdesc;
|
||||
Datum values[3];
|
||||
bool nulls[3];
|
||||
bool nulls[3] = {0};
|
||||
|
||||
rel = relation_open(relid, AccessShareLock);
|
||||
|
||||
@ -130,7 +129,6 @@ pg_visibility(PG_FUNCTION_ARGS)
|
||||
errmsg("invalid block number")));
|
||||
|
||||
tupdesc = pg_visibility_tupdesc(false, true);
|
||||
MemSet(nulls, 0, sizeof(nulls));
|
||||
|
||||
mapbits = (int32) visibilitymap_get_status(rel, blkno, &vmbuffer);
|
||||
if (vmbuffer != InvalidBuffer)
|
||||
@ -188,10 +186,9 @@ pg_visibility_map_rel(PG_FUNCTION_ARGS)
|
||||
if (info->next < info->count)
|
||||
{
|
||||
Datum values[3];
|
||||
bool nulls[3];
|
||||
bool nulls[3] = {0};
|
||||
HeapTuple tuple;
|
||||
|
||||
MemSet(nulls, 0, sizeof(nulls));
|
||||
values[0] = Int64GetDatum(info->next);
|
||||
values[1] = BoolGetDatum((info->bits[info->next] & (1 << 0)) != 0);
|
||||
values[2] = BoolGetDatum((info->bits[info->next] & (1 << 1)) != 0);
|
||||
@ -233,10 +230,9 @@ pg_visibility_rel(PG_FUNCTION_ARGS)
|
||||
if (info->next < info->count)
|
||||
{
|
||||
Datum values[4];
|
||||
bool nulls[4];
|
||||
bool nulls[4] = {0};
|
||||
HeapTuple tuple;
|
||||
|
||||
MemSet(nulls, 0, sizeof(nulls));
|
||||
values[0] = Int64GetDatum(info->next);
|
||||
values[1] = BoolGetDatum((info->bits[info->next] & (1 << 0)) != 0);
|
||||
values[2] = BoolGetDatum((info->bits[info->next] & (1 << 1)) != 0);
|
||||
@ -266,7 +262,7 @@ pg_visibility_map_summary(PG_FUNCTION_ARGS)
|
||||
int64 all_frozen = 0;
|
||||
TupleDesc tupdesc;
|
||||
Datum values[2];
|
||||
bool nulls[2];
|
||||
bool nulls[2] = {0};
|
||||
|
||||
rel = relation_open(relid, AccessShareLock);
|
||||
|
||||
@ -300,7 +296,6 @@ pg_visibility_map_summary(PG_FUNCTION_ARGS)
|
||||
TupleDescInitEntry(tupdesc, (AttrNumber) 2, "all_frozen", INT8OID, -1, 0);
|
||||
tupdesc = BlessTupleDesc(tupdesc);
|
||||
|
||||
MemSet(nulls, 0, sizeof(nulls));
|
||||
values[0] = Int64GetDatum(all_visible);
|
||||
values[1] = Int64GetDatum(all_frozen);
|
||||
|
||||
|
Reference in New Issue
Block a user