mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +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:
@ -238,7 +238,7 @@ hash_page_stats(PG_FUNCTION_ARGS)
|
||||
Page page;
|
||||
int j;
|
||||
Datum values[9];
|
||||
bool nulls[9];
|
||||
bool nulls[9] = {0};
|
||||
HashPageStat stat;
|
||||
HeapTuple tuple;
|
||||
TupleDesc tupleDesc;
|
||||
@ -261,8 +261,6 @@ hash_page_stats(PG_FUNCTION_ARGS)
|
||||
elog(ERROR, "return type must be a row type");
|
||||
tupleDesc = BlessTupleDesc(tupleDesc);
|
||||
|
||||
MemSet(nulls, 0, sizeof(nulls));
|
||||
|
||||
j = 0;
|
||||
values[j++] = Int32GetDatum(stat.live_items);
|
||||
values[j++] = Int32GetDatum(stat.dead_items);
|
||||
@ -303,7 +301,7 @@ hash_page_items(PG_FUNCTION_ARGS)
|
||||
Page page;
|
||||
Datum result;
|
||||
Datum values[3];
|
||||
bool nulls[3];
|
||||
bool nulls[3] = {0};
|
||||
uint32 hashkey;
|
||||
HeapTuple tuple;
|
||||
FuncCallContext *fctx;
|
||||
@ -361,8 +359,6 @@ hash_page_items(PG_FUNCTION_ARGS)
|
||||
|
||||
itup = (IndexTuple) PageGetItem(uargs->page, id);
|
||||
|
||||
MemSet(nulls, 0, sizeof(nulls));
|
||||
|
||||
j = 0;
|
||||
values[j++] = Int32GetDatum((int32) uargs->offset);
|
||||
values[j++] = PointerGetDatum(&itup->t_tid);
|
||||
@ -409,7 +405,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
|
||||
int i,
|
||||
j;
|
||||
Datum values[3];
|
||||
bool nulls[3];
|
||||
bool nulls[3] = {0};
|
||||
uint32 *freep;
|
||||
|
||||
if (!superuser())
|
||||
@ -495,8 +491,6 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
|
||||
elog(ERROR, "return type must be a row type");
|
||||
tupleDesc = BlessTupleDesc(tupleDesc);
|
||||
|
||||
MemSet(nulls, 0, sizeof(nulls));
|
||||
|
||||
j = 0;
|
||||
values[j++] = Int64GetDatum((int64) bitmapblkno);
|
||||
values[j++] = Int32GetDatum(bitmapbit);
|
||||
@ -526,7 +520,7 @@ hash_metapage_info(PG_FUNCTION_ARGS)
|
||||
int i,
|
||||
j;
|
||||
Datum values[16];
|
||||
bool nulls[16];
|
||||
bool nulls[16] = {0};
|
||||
Datum spares[HASH_MAX_SPLITPOINTS];
|
||||
Datum mapp[HASH_MAX_BITMAPS];
|
||||
|
||||
@ -544,8 +538,6 @@ hash_metapage_info(PG_FUNCTION_ARGS)
|
||||
|
||||
metad = HashPageGetMeta(page);
|
||||
|
||||
MemSet(nulls, 0, sizeof(nulls));
|
||||
|
||||
j = 0;
|
||||
values[j++] = Int64GetDatum((int64) metad->hashm_magic);
|
||||
values[j++] = Int64GetDatum((int64) metad->hashm_version);
|
||||
|
Reference in New Issue
Block a user