diff options
author | Peter Eisentraut | 2022-07-16 06:42:15 +0000 |
---|---|---|
committer | Peter Eisentraut | 2022-07-16 06:50:49 +0000 |
commit | 9fd45870c1436b477264c0c82eb195df52bc0919 (patch) | |
tree | 10a09724c0bcffa8f58f262e50c3260cde484446 /contrib/pageinspect/hashfuncs.c | |
parent | c94ae9d827a360d74da6a304692d34a4dc8b6445 (diff) |
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
Diffstat (limited to 'contrib/pageinspect/hashfuncs.c')
-rw-r--r-- | contrib/pageinspect/hashfuncs.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c index 5287dbe1a30..81815392d70 100644 --- a/contrib/pageinspect/hashfuncs.c +++ b/contrib/pageinspect/hashfuncs.c @@ -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); |