diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index c875f3e5a2..71defb9cc6 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -558,8 +558,8 @@ report_corruption_internal(Tuplestorestate *tupstore, TupleDesc tupdesc,
 	bool		nulls[HEAPCHECK_RELATION_COLS];
 	HeapTuple	tuple;
 
-	MemSet(values, 0, sizeof(values));
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(values, 0, sizeof(values));
+	memset(nulls, 0, sizeof(nulls));
 	values[0] = Int64GetDatum(blkno);
 	values[1] = Int32GetDatum(offnum);
 	values[2] = Int32GetDatum(attnum);
diff --git a/contrib/bloom/blcost.c b/contrib/bloom/blcost.c
index d42e4e9628..cf3291375e 100644
--- a/contrib/bloom/blcost.c
+++ b/contrib/bloom/blcost.c
@@ -28,7 +28,7 @@ blcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
 	IndexOptInfo *index = path->indexinfo;
 	GenericCosts costs;
 
-	MemSet(&costs, 0, sizeof(costs));
+	memset(&costs, 0, sizeof(costs));
 
 	/* We have to visit all index tuples anyway */
 	costs.numIndexTuples = index->tuples;
diff --git a/contrib/hstore/hstore_gist.c b/contrib/hstore/hstore_gist.c
index 102c9cea72..016bfa4a4c 100644
--- a/contrib/hstore/hstore_gist.c
+++ b/contrib/hstore/hstore_gist.c
@@ -459,7 +459,7 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
 			if (ISALLTRUE(datum_l) || ISALLTRUE(_j))
 			{
 				if (!ISALLTRUE(datum_l))
-					MemSet((void *) union_l, 0xff, siglen);
+					memset((void *) union_l, 0xff, siglen);
 			}
 			else
 			{
@@ -475,7 +475,7 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
 			if (ISALLTRUE(datum_r) || ISALLTRUE(_j))
 			{
 				if (!ISALLTRUE(datum_r))
-					MemSet((void *) union_r, 0xff, siglen);
+					memset((void *) union_r, 0xff, siglen);
 			}
 			else
 			{
diff --git a/contrib/hstore/hstore_io.c b/contrib/hstore/hstore_io.c
index b3304ff844..2c871c6d93 100644
--- a/contrib/hstore/hstore_io.c
+++ b/contrib/hstore/hstore_io.c
@@ -841,7 +841,7 @@ hstore_from_record(PG_FUNCTION_ARGS)
 	if (my_extra->record_type != tupType ||
 		my_extra->record_typmod != tupTypmod)
 	{
-		MemSet(my_extra, 0,
+		memset(my_extra, 0,
 			   offsetof(RecordIOData, columns) +
 			   ncolumns * sizeof(ColumnIOData));
 		my_extra->record_type = tupType;
@@ -1035,7 +1035,7 @@ hstore_populate_record(PG_FUNCTION_ARGS)
 	if (my_extra->record_type != tupType ||
 		my_extra->record_typmod != tupTypmod)
 	{
-		MemSet(my_extra, 0,
+		memset(my_extra, 0,
 			   offsetof(RecordIOData, columns) +
 			   ncolumns * sizeof(ColumnIOData));
 		my_extra->record_type = tupType;
diff --git a/contrib/intarray/_intbig_gist.c b/contrib/intarray/_intbig_gist.c
index 18ecd8cda6..c9d8f9b84d 100644
--- a/contrib/intarray/_intbig_gist.c
+++ b/contrib/intarray/_intbig_gist.c
@@ -420,7 +420,7 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
 			if (ISALLTRUE(datum_l) || ISALLTRUE(_j))
 			{
 				if (!ISALLTRUE(datum_l))
-					MemSet((void *) union_l, 0xff, siglen);
+					memset((void *) union_l, 0xff, siglen);
 			}
 			else
 			{
@@ -436,7 +436,7 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
 			if (ISALLTRUE(datum_r) || ISALLTRUE(_j))
 			{
 				if (!ISALLTRUE(datum_r))
-					MemSet((void *) union_r, 0xff, siglen);
+					memset((void *) union_r, 0xff, siglen);
 			}
 			else
 			{
diff --git a/contrib/ltree/_ltree_gist.c b/contrib/ltree/_ltree_gist.c
index 72516c3b6b..2dc59f8a0f 100644
--- a/contrib/ltree/_ltree_gist.c
+++ b/contrib/ltree/_ltree_gist.c
@@ -345,7 +345,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
 			if (LTG_ISALLTRUE(datum_l) || LTG_ISALLTRUE(_j))
 			{
 				if (!LTG_ISALLTRUE(datum_l))
-					MemSet((void *) union_l, 0xff, siglen);
+					memset((void *) union_l, 0xff, siglen);
 			}
 			else
 			{
@@ -361,7 +361,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
 			if (LTG_ISALLTRUE(datum_r) || LTG_ISALLTRUE(_j))
 			{
 				if (!LTG_ISALLTRUE(datum_r))
-					MemSet((void *) union_r, 0xff, siglen);
+					memset((void *) union_r, 0xff, siglen);
 			}
 			else
 			{
diff --git a/contrib/oid2name/oid2name.c b/contrib/oid2name/oid2name.c
index a62a5eedb1..a3e358bb1b 100644
--- a/contrib/oid2name/oid2name.c
+++ b/contrib/oid2name/oid2name.c
@@ -424,7 +424,7 @@ sql_exec(PGconn *conn, const char *todo, bool quiet)
 		}
 		fprintf(stdout, "\n");
 		pad = (char *) pg_malloc(l + 1);
-		MemSet(pad, '-', l);
+		memset(pad, '-', l);
 		pad[l] = '\0';
 		fprintf(stdout, "%s\n", pad);
 		free(pad);
diff --git a/contrib/pageinspect/brinfuncs.c b/contrib/pageinspect/brinfuncs.c
index 879276e6de..b82cb2b5a1 100644
--- a/contrib/pageinspect/brinfuncs.c
+++ b/contrib/pageinspect/brinfuncs.c
@@ -230,7 +230,7 @@ brin_page_items(PG_FUNCTION_ARGS)
 		else
 			attno++;
 
-		MemSet(nulls, 0, sizeof(nulls));
+		memset(nulls, 0, sizeof(nulls));
 
 		if (unusedItem)
 		{
@@ -354,7 +354,7 @@ brin_metapage_info(PG_FUNCTION_ARGS)
 
 	/* Extract values from the metapage */
 	meta = (BrinMetaPageData *) PageGetContents(page);
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(nulls, 0, sizeof(nulls));
 	values[0] = CStringGetTextDatum(psprintf("0x%08X", meta->brinMagic));
 	values[1] = Int32GetDatum(meta->brinVersion);
 	values[2] = Int32GetDatum(meta->pagesPerRange);
diff --git a/contrib/pageinspect/hashfuncs.c b/contrib/pageinspect/hashfuncs.c
index 69af7b962f..4ae6bc0518 100644
--- a/contrib/pageinspect/hashfuncs.c
+++ b/contrib/pageinspect/hashfuncs.c
@@ -261,7 +261,7 @@ hash_page_stats(PG_FUNCTION_ARGS)
 		elog(ERROR, "return type must be a row type");
 	tupleDesc = BlessTupleDesc(tupleDesc);
 
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(nulls, 0, sizeof(nulls));
 
 	j = 0;
 	values[j++] = Int32GetDatum(stat.live_items);
@@ -361,7 +361,7 @@ hash_page_items(PG_FUNCTION_ARGS)
 
 		itup = (IndexTuple) PageGetItem(uargs->page, id);
 
-		MemSet(nulls, 0, sizeof(nulls));
+		memset(nulls, 0, sizeof(nulls));
 
 		j = 0;
 		values[j++] = Int32GetDatum((int32) uargs->offset);
@@ -495,7 +495,7 @@ hash_bitmap_info(PG_FUNCTION_ARGS)
 		elog(ERROR, "return type must be a row type");
 	tupleDesc = BlessTupleDesc(tupleDesc);
 
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(nulls, 0, sizeof(nulls));
 
 	j = 0;
 	values[j++] = Int64GetDatum((int64) bitmapblkno);
@@ -544,7 +544,7 @@ hash_metapage_info(PG_FUNCTION_ARGS)
 
 	metad = HashPageGetMeta(page);
 
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(nulls, 0, sizeof(nulls));
 
 	j = 0;
 	values[j++] = Int64GetDatum((int64) metad->hashm_magic);
diff --git a/contrib/pageinspect/heapfuncs.c b/contrib/pageinspect/heapfuncs.c
index 3dd1a9bc2a..dac5b78efe 100644
--- a/contrib/pageinspect/heapfuncs.c
+++ b/contrib/pageinspect/heapfuncs.c
@@ -531,8 +531,8 @@ heap_tuple_infomask_flags(PG_FUNCTION_ARGS)
 		pg_popcount((const char *) &t_infomask2, sizeof(uint16));
 
 	/* Initialize values and NULL flags arrays */
-	MemSet(values, 0, sizeof(values));
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(values, 0, sizeof(values));
+	memset(nulls, 0, sizeof(nulls));
 
 	/* If no flags, return a set of empty arrays */
 	if (bitcnt <= 0)
@@ -598,7 +598,7 @@ heap_tuple_infomask_flags(PG_FUNCTION_ARGS)
 	 * keeps the code simple.
 	 */
 	cnt = 0;
-	MemSet(flags, 0, sizeof(Datum) * bitcnt);
+	memset(flags, 0, sizeof(Datum) * bitcnt);
 
 	/* decode combined masks of t_infomask */
 	if ((t_infomask & HEAP_XMAX_SHR_LOCK) == HEAP_XMAX_SHR_LOCK)
diff --git a/contrib/pg_prewarm/autoprewarm.c b/contrib/pg_prewarm/autoprewarm.c
index c0c4f5d9ca..9daeb06950 100644
--- a/contrib/pg_prewarm/autoprewarm.c
+++ b/contrib/pg_prewarm/autoprewarm.c
@@ -819,7 +819,7 @@ apw_start_leader_worker(void)
 	BgwHandleStatus status;
 	pid_t		pid;
 
-	MemSet(&worker, 0, sizeof(BackgroundWorker));
+	memset(&worker, 0, sizeof(BackgroundWorker));
 	worker.bgw_flags = BGWORKER_SHMEM_ACCESS;
 	worker.bgw_start_time = BgWorkerStart_ConsistentState;
 	strcpy(worker.bgw_library_name, "pg_prewarm");
@@ -859,7 +859,7 @@ apw_start_database_worker(void)
 	BackgroundWorker worker;
 	BackgroundWorkerHandle *handle;
 
-	MemSet(&worker, 0, sizeof(BackgroundWorker));
+	memset(&worker, 0, sizeof(BackgroundWorker));
 	worker.bgw_flags =
 		BGWORKER_SHMEM_ACCESS | BGWORKER_BACKEND_DATABASE_CONNECTION;
 	worker.bgw_start_time = BgWorkerStart_ConsistentState;
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index 768cedd91a..cdf1267c0a 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -1869,8 +1869,8 @@ pg_stat_statements_info(PG_FUNCTION_ARGS)
 	if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
 		elog(ERROR, "return type must be a row type");
 
-	MemSet(values, 0, sizeof(values));
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(values, 0, sizeof(values));
+	memset(nulls, 0, sizeof(nulls));
 
 	/* Read global statistics for pg_stat_statements */
 	{
diff --git a/contrib/pg_trgm/trgm_gist.c b/contrib/pg_trgm/trgm_gist.c
index 6f28db7d1e..36f4f41019 100644
--- a/contrib/pg_trgm/trgm_gist.c
+++ b/contrib/pg_trgm/trgm_gist.c
@@ -95,7 +95,7 @@ makesign(BITVECP sign, TRGM *a, int siglen)
 	trgm	   *ptr = GETARR(a);
 	int32		tmp = 0;
 
-	MemSet((void *) sign, 0, siglen);
+	memset((void *) sign, 0, siglen);
 	SETBIT(sign, SIGLENBIT(siglen));	/* set last unused bit */
 	for (k = 0; k < len; k++)
 	{
@@ -914,7 +914,7 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
 			if (ISALLTRUE(datum_l) || cache[j].allistrue)
 			{
 				if (!ISALLTRUE(datum_l))
-					MemSet((void *) GETSIGN(datum_l), 0xff, siglen);
+					memset((void *) GETSIGN(datum_l), 0xff, siglen);
 			}
 			else
 			{
@@ -930,7 +930,7 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
 			if (ISALLTRUE(datum_r) || cache[j].allistrue)
 			{
 				if (!ISALLTRUE(datum_r))
-					MemSet((void *) GETSIGN(datum_r), 0xff, siglen);
+					memset((void *) GETSIGN(datum_r), 0xff, siglen);
 			}
 			else
 			{
diff --git a/contrib/pg_trgm/trgm_regexp.c b/contrib/pg_trgm/trgm_regexp.c
index 58d32ba946..0eabafdd0f 100644
--- a/contrib/pg_trgm/trgm_regexp.c
+++ b/contrib/pg_trgm/trgm_regexp.c
@@ -926,7 +926,7 @@ transformGraph(TrgmNFA *trgmNFA)
 	trgmNFA->nstates = 0;
 
 	/* Create initial state: ambiguous prefix, NFA's initial state */
-	MemSet(&initkey, 0, sizeof(initkey));
+	memset(&initkey, 0, sizeof(initkey));
 	initkey.prefix.colors[0] = COLOR_UNKNOWN;
 	initkey.prefix.colors[1] = COLOR_UNKNOWN;
 	initkey.nstate = pg_reg_getinitialstate(trgmNFA->regex);
@@ -1028,7 +1028,7 @@ addKey(TrgmNFA *trgmNFA, TrgmState *state, TrgmStateKey *key)
 	 * Ensure any pad bytes in destKey are zero, since it may get used as a
 	 * hashtable key by getState.
 	 */
-	MemSet(&destKey, 0, sizeof(destKey));
+	memset(&destKey, 0, sizeof(destKey));
 
 	/*
 	 * Compare key to each existing enter key of the state to check for
@@ -1209,7 +1209,7 @@ addArcs(TrgmNFA *trgmNFA, TrgmState *state)
 	 * Ensure any pad bytes in destKey are zero, since it may get used as a
 	 * hashtable key by getState.
 	 */
-	MemSet(&destKey, 0, sizeof(destKey));
+	memset(&destKey, 0, sizeof(destKey));
 
 	/*
 	 * Iterate over enter keys associated with this expanded-graph state. This
diff --git a/contrib/pg_visibility/pg_visibility.c b/contrib/pg_visibility/pg_visibility.c
index 1853c354e3..fbb37bd003 100644
--- a/contrib/pg_visibility/pg_visibility.c
+++ b/contrib/pg_visibility/pg_visibility.c
@@ -88,7 +88,7 @@ pg_visibility_map(PG_FUNCTION_ARGS)
 				 errmsg("invalid block number")));
 
 	tupdesc = pg_visibility_tupdesc(false, false);
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(nulls, 0, sizeof(nulls));
 
 	mapbits = (int32) visibilitymap_get_status(rel, blkno, &vmbuffer);
 	if (vmbuffer != InvalidBuffer)
@@ -130,7 +130,7 @@ pg_visibility(PG_FUNCTION_ARGS)
 				 errmsg("invalid block number")));
 
 	tupdesc = pg_visibility_tupdesc(false, true);
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(nulls, 0, sizeof(nulls));
 
 	mapbits = (int32) visibilitymap_get_status(rel, blkno, &vmbuffer);
 	if (vmbuffer != InvalidBuffer)
@@ -191,7 +191,7 @@ pg_visibility_map_rel(PG_FUNCTION_ARGS)
 		bool		nulls[3];
 		HeapTuple	tuple;
 
-		MemSet(nulls, 0, sizeof(nulls));
+		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);
@@ -236,7 +236,7 @@ pg_visibility_rel(PG_FUNCTION_ARGS)
 		bool		nulls[4];
 		HeapTuple	tuple;
 
-		MemSet(nulls, 0, sizeof(nulls));
+		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);
@@ -300,7 +300,7 @@ pg_visibility_map_summary(PG_FUNCTION_ARGS)
 	TupleDescInitEntry(tupdesc, (AttrNumber) 2, "all_frozen", INT8OID, -1, 0);
 	tupdesc = BlessTupleDesc(tupdesc);
 
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(nulls, 0, sizeof(nulls));
 	values[0] = Int64GetDatum(all_visible);
 	values[1] = Int64GetDatum(all_frozen);
 
diff --git a/contrib/pg_walinspect/pg_walinspect.c b/contrib/pg_walinspect/pg_walinspect.c
index a082dfb331..7589f80b0e 100644
--- a/contrib/pg_walinspect/pg_walinspect.c
+++ b/contrib/pg_walinspect/pg_walinspect.c
@@ -266,8 +266,8 @@ 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));
+	memset(values, 0, sizeof(values));
+	memset(nulls, 0, sizeof(nulls));
 
 	GetWALRecordInfo(xlogreader, first_record, values, nulls,
 					 PG_GET_WAL_RECORD_INFO_COLS);
@@ -343,8 +343,8 @@ GetWALRecordsInfo(FunctionCallInfo fcinfo, XLogRecPtr start_lsn,
 
 	Assert(xlogreader);
 
-	MemSet(values, 0, sizeof(values));
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(values, 0, sizeof(values));
+	memset(nulls, 0, sizeof(nulls));
 
 	while (ReadNextXLogRecord(xlogreader, first_record) &&
 		   xlogreader->EndRecPtr <= end_lsn)
@@ -565,7 +565,7 @@ GetWalStats(FunctionCallInfo fcinfo, XLogRecPtr start_lsn,
 
 	xlogreader = InitXLogReaderState(start_lsn, &first_record);
 
-	MemSet(&stats, 0, sizeof(stats));
+	memset(&stats, 0, sizeof(stats));
 
 	while (ReadNextXLogRecord(xlogreader, first_record) &&
 		   xlogreader->EndRecPtr <= end_lsn)
@@ -578,8 +578,8 @@ GetWalStats(FunctionCallInfo fcinfo, XLogRecPtr start_lsn,
 	pfree(xlogreader->private_data);
 	XLogReaderFree(xlogreader);
 
-	MemSet(values, 0, sizeof(values));
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(values, 0, sizeof(values));
+	memset(nulls, 0, sizeof(nulls));
 
 	GetXLogSummaryStats(&stats, rsinfo, values, nulls,
 						PG_GET_WAL_STATS_COLS,
diff --git a/contrib/pgstattuple/pgstatindex.c b/contrib/pgstattuple/pgstatindex.c
index e1048e47ff..eae3909664 100644
--- a/contrib/pgstattuple/pgstatindex.c
+++ b/contrib/pgstattuple/pgstatindex.c
@@ -697,7 +697,7 @@ pgstathashindex(PG_FUNCTION_ARGS)
 	/*
 	 * Build and return the tuple
 	 */
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(nulls, 0, sizeof(nulls));
 	values[0] = Int32GetDatum(stats.version);
 	values[1] = Int64GetDatum((int64) stats.bucket_pages);
 	values[2] = Int64GetDatum((int64) stats.overflow_pages);
diff --git a/contrib/postgres_fdw/connection.c b/contrib/postgres_fdw/connection.c
index 061ffaf329..aa6dbac347 100644
--- a/contrib/postgres_fdw/connection.c
+++ b/contrib/postgres_fdw/connection.c
@@ -1687,8 +1687,8 @@ postgres_fdw_get_connections(PG_FUNCTION_ARGS)
 
 		server = GetForeignServerExtended(entry->serverid, FSV_MISSING_OK);
 
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, 0, sizeof(nulls));
+		memset(values, 0, sizeof(values));
+		memset(nulls, 0, sizeof(nulls));
 
 		/*
 		 * The foreign server may have been dropped in current explicit
diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index d56951153b..38b5c46f40 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -3332,7 +3332,7 @@ estimate_path_cost_size(PlannerInfo *root,
 			input_rows = ofpinfo->rows;
 
 			/* Collect statistics about aggregates for estimating costs. */
-			MemSet(&aggcosts, 0, sizeof(AggClauseCosts));
+			memset(&aggcosts, 0, sizeof(AggClauseCosts));
 			if (root->parse->hasAggs)
 			{
 				get_agg_clause_costs(root, AGGSPLIT_SIMPLE, &aggcosts);
diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c
index e308228bde..bd6f6614f6 100644
--- a/contrib/tablefunc/tablefunc.c
+++ b/contrib/tablefunc/tablefunc.c
@@ -129,7 +129,7 @@ typedef struct crosstab_cat_desc
 do { \
 	crosstab_HashEnt *hentry; char key[MAX_CATNAME_LEN]; \
 	\
-	MemSet(key, 0, MAX_CATNAME_LEN); \
+	memset(key, 0, MAX_CATNAME_LEN); \
 	snprintf(key, MAX_CATNAME_LEN - 1, "%s", CATNAME); \
 	hentry = (crosstab_HashEnt*) hash_search(HASHTAB, \
 										 key, HASH_FIND, NULL); \
@@ -143,7 +143,7 @@ do { \
 do { \
 	crosstab_HashEnt *hentry; bool found; char key[MAX_CATNAME_LEN]; \
 	\
-	MemSet(key, 0, MAX_CATNAME_LEN); \
+	memset(key, 0, MAX_CATNAME_LEN); \
 	snprintf(key, MAX_CATNAME_LEN - 1, "%s", CATDESC->catname); \
 	hentry = (crosstab_HashEnt*) hash_search(HASHTAB, \
 										 key, HASH_ENTER, &found); \
diff --git a/src/backend/access/common/scankey.c b/src/backend/access/common/scankey.c
index ff2b608f2e..2355ac54ef 100644
--- a/src/backend/access/common/scankey.c
+++ b/src/backend/access/common/scankey.c
@@ -51,7 +51,7 @@ ScanKeyEntryInitialize(ScanKey entry,
 	else
 	{
 		Assert(flags & (SK_SEARCHNULL | SK_SEARCHNOTNULL));
-		MemSet(&entry->sk_func, 0, sizeof(entry->sk_func));
+		memset(&entry->sk_func, 0, sizeof(entry->sk_func));
 	}
 }
 
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index 9f41b1e854..8eb8575a5d 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -611,7 +611,7 @@ TupleDescInitEntry(TupleDesc desc,
 	 * attributes. Also, do nothing if caller wants to re-use the old attname.
 	 */
 	if (attributeName == NULL)
-		MemSet(NameStr(att->attname), 0, NAMEDATALEN);
+		memset(NameStr(att->attname), 0, NAMEDATALEN);
 	else if (attributeName != NameStr(att->attname))
 		namestrcpy(&(att->attname), attributeName);
 
diff --git a/src/backend/access/gin/ginutil.c b/src/backend/access/gin/ginutil.c
index 3d15701a01..01a365aad6 100644
--- a/src/backend/access/gin/ginutil.c
+++ b/src/backend/access/gin/ginutil.c
@@ -98,7 +98,7 @@ initGinState(GinState *state, Relation index)
 	TupleDesc	origTupdesc = RelationGetDescr(index);
 	int			i;
 
-	MemSet(state, 0, sizeof(GinState));
+	memset(state, 0, sizeof(GinState));
 
 	state->index = index;
 	state->oneCol = (origTupdesc->natts == 1);
diff --git a/src/backend/access/hash/hashovfl.c b/src/backend/access/hash/hashovfl.c
index e34cfc302d..86aa48d520 100644
--- a/src/backend/access/hash/hashovfl.c
+++ b/src/backend/access/hash/hashovfl.c
@@ -760,7 +760,7 @@ _hash_initbitmapbuffer(Buffer buf, uint16 bmsize, bool initpage)
 
 	/* set all of the bits to 1 */
 	freep = HashPageGetBitmap(pg);
-	MemSet(freep, 0xFF, bmsize);
+	memset(freep, 0xFF, bmsize);
 
 	/*
 	 * Set pd_lower just past the end of the bitmap page data.  We could even
diff --git a/src/backend/access/hash/hashpage.c b/src/backend/access/hash/hashpage.c
index 39206d1942..3f31dad231 100644
--- a/src/backend/access/hash/hashpage.c
+++ b/src/backend/access/hash/hashpage.c
@@ -572,8 +572,8 @@ _hash_init_metabuffer(Buffer buf, double num_tuples, RegProcedure procid,
 	metap->hashm_highmask = pg_nextpower2_32(num_buckets + 1) - 1;
 	metap->hashm_lowmask = (metap->hashm_highmask >> 1);
 
-	MemSet(metap->hashm_spares, 0, sizeof(metap->hashm_spares));
-	MemSet(metap->hashm_mapp, 0, sizeof(metap->hashm_mapp));
+	memset(metap->hashm_spares, 0, sizeof(metap->hashm_spares));
+	memset(metap->hashm_mapp, 0, sizeof(metap->hashm_mapp));
 
 	/* Set up mapping for one spare page after the initial splitpoints */
 	metap->hashm_spares[spare_index] = 1;
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 7421851027..dffa798aad 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -9141,7 +9141,7 @@ heap_xlog_insert(XLogReaderState *record)
 		data += SizeOfHeapHeader;
 
 		htup = &tbuf.hdr;
-		MemSet((char *) htup, 0, SizeofHeapTupleHeader);
+		memset((char *) htup, 0, SizeofHeapTupleHeader);
 		/* PG73FORMAT: get bitmap [+ padding] [+ oid] + data */
 		memcpy((char *) htup + SizeofHeapTupleHeader,
 			   data,
@@ -9282,7 +9282,7 @@ heap_xlog_multi_insert(XLogReaderState *record)
 			newlen = xlhdr->datalen;
 			Assert(newlen <= MaxHeapTupleSize);
 			htup = &tbuf.hdr;
-			MemSet((char *) htup, 0, SizeofHeapTupleHeader);
+			memset((char *) htup, 0, SizeofHeapTupleHeader);
 			/* PG73FORMAT: get bitmap [+ padding] [+ oid] + data */
 			memcpy((char *) htup + SizeofHeapTupleHeader,
 				   (char *) tupdata,
@@ -9518,7 +9518,7 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
 		Assert(tuplen <= MaxHeapTupleSize);
 
 		htup = &tbuf.hdr;
-		MemSet((char *) htup, 0, SizeofHeapTupleHeader);
+		memset((char *) htup, 0, SizeofHeapTupleHeader);
 
 		/*
 		 * Reconstruct the new tuple using the prefix and/or suffix from the
diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c
index 9f43bbe25f..c375c01804 100644
--- a/src/backend/access/heap/pruneheap.c
+++ b/src/backend/access/heap/pruneheap.c
@@ -1113,7 +1113,7 @@ heap_get_root_tuples(Page page, OffsetNumber *root_offsets)
 	OffsetNumber offnum,
 				maxoff;
 
-	MemSet(root_offsets, InvalidOffsetNumber,
+	memset(root_offsets, InvalidOffsetNumber,
 		   MaxHeapTuplesPerPage * sizeof(OffsetNumber));
 
 	maxoff = PageGetMaxOffsetNumber(page);
diff --git a/src/backend/access/heap/visibilitymap.c b/src/backend/access/heap/visibilitymap.c
index e09f25a684..f3fa73df81 100644
--- a/src/backend/access/heap/visibilitymap.c
+++ b/src/backend/access/heap/visibilitymap.c
@@ -494,7 +494,7 @@ visibilitymap_prepare_truncate(Relation rel, BlockNumber nheapblocks)
 		START_CRIT_SECTION();
 
 		/* Clear out the unwanted bytes. */
-		MemSet(&map[truncByte + 1], 0, MAPSIZE - (truncByte + 1));
+		memset(&map[truncByte + 1], 0, MAPSIZE - (truncByte + 1));
 
 		/*----
 		 * Mask out the unwanted bits of the last remaining byte.
diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c
index 20adb602a4..129c4383ae 100644
--- a/src/backend/access/nbtree/nbtpage.c
+++ b/src/backend/access/nbtree/nbtpage.c
@@ -2220,7 +2220,7 @@ _bt_mark_page_halfdead(Relation rel, Buffer leafbuf, BTStack stack)
 	opaque->btpo_flags |= BTP_HALF_DEAD;
 
 	Assert(PageGetMaxOffsetNumber(page) == P_HIKEY);
-	MemSet(&trunctuple, 0, sizeof(IndexTupleData));
+	memset(&trunctuple, 0, sizeof(IndexTupleData));
 	trunctuple.t_info = sizeof(IndexTupleData);
 	if (topparent != leafblkno)
 		BTreeTupleSetTopParent(&trunctuple, topparent);
diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c
index f9186ca233..e40b586e97 100644
--- a/src/backend/access/nbtree/nbtxlog.c
+++ b/src/backend/access/nbtree/nbtxlog.c
@@ -780,7 +780,7 @@ btree_xlog_mark_page_halfdead(uint8 info, XLogReaderState *record)
 	 * Construct a dummy high key item that points to top parent page (value
 	 * is InvalidBlockNumber when the top parent page is the leaf page itself)
 	 */
-	MemSet(&trunctuple, 0, sizeof(IndexTupleData));
+	memset(&trunctuple, 0, sizeof(IndexTupleData));
 	trunctuple.t_info = sizeof(IndexTupleData);
 	BTreeTupleSetTopParent(&trunctuple, xlrec->topparent);
 
@@ -915,7 +915,7 @@ btree_xlog_unlink_page(uint8 info, XLogReaderState *record)
 		pageop->btpo_cycleid = 0;
 
 		/* Add a dummy hikey item */
-		MemSet(&trunctuple, 0, sizeof(IndexTupleData));
+		memset(&trunctuple, 0, sizeof(IndexTupleData));
 		trunctuple.t_info = sizeof(IndexTupleData);
 		BTreeTupleSetTopParent(&trunctuple, xlrec->leaftopparent);
 
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 3d9088a704..7e655c49b6 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -804,7 +804,7 @@ TrimCLOG(void)
 		/* Zero so-far-unused positions in the current byte */
 		*byteptr &= (1 << bshift) - 1;
 		/* Zero the rest of the page */
-		MemSet(byteptr + 1, 0, BLCKSZ - byteno - 1);
+		memset(byteptr + 1, 0, BLCKSZ - byteno - 1);
 
 		XactCtl->shared->page_dirty[slotno] = true;
 	}
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 8f7d12950e..8b52f73800 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -1872,7 +1872,7 @@ MultiXactShmemInit(void)
 		Assert(!found);
 
 		/* Make sure we zero out the per-backend state */
-		MemSet(MultiXactState, 0, SHARED_MULTIXACT_STATE_SIZE);
+		memset(MultiXactState, 0, SHARED_MULTIXACT_STATE_SIZE);
 	}
 	else
 		Assert(found);
@@ -2072,7 +2072,7 @@ TrimMultiXact(void)
 		offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
 		offptr += entryno;
 
-		MemSet(offptr, 0, BLCKSZ - (entryno * sizeof(MultiXactOffset)));
+		memset(offptr, 0, BLCKSZ - (entryno * sizeof(MultiXactOffset)));
 
 		MultiXactOffsetCtl->shared->page_dirty[slotno] = true;
 	}
@@ -2104,7 +2104,7 @@ TrimMultiXact(void)
 		xidptr = (TransactionId *)
 			(MultiXactMemberCtl->shared->page_buffer[slotno] + memberoff);
 
-		MemSet(xidptr, 0, BLCKSZ - memberoff);
+		memset(xidptr, 0, BLCKSZ - memberoff);
 
 		/*
 		 * Note: we don't need to zero out the flag bits in the remaining
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index b65cb49d7f..3781af2dee 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -296,7 +296,7 @@ SimpleLruZeroPage(SlruCtl ctl, int pageno)
 	SlruRecentlyUsed(shared, slotno);
 
 	/* Set the buffer to zeroes */
-	MemSet(shared->page_buffer[slotno], 0, BLCKSZ);
+	memset(shared->page_buffer[slotno], 0, BLCKSZ);
 
 	/* Set the LSNs for this new page to zero */
 	SimpleLruZeroLSNs(ctl, slotno);
@@ -326,7 +326,7 @@ SimpleLruZeroLSNs(SlruCtl ctl, int slotno)
 	SlruShared	shared = ctl->shared;
 
 	if (shared->lsn_groups_per_page > 0)
-		MemSet(&shared->group_lsn[slotno * shared->lsn_groups_per_page], 0,
+		memset(&shared->group_lsn[slotno * shared->lsn_groups_per_page], 0,
 			   shared->lsn_groups_per_page * sizeof(XLogRecPtr));
 }
 
@@ -712,7 +712,7 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
 		ereport(LOG,
 				(errmsg("file \"%s\" doesn't exist, reading as zeroes",
 						path)));
-		MemSet(shared->page_buffer[slotno], 0, BLCKSZ);
+		memset(shared->page_buffer[slotno], 0, BLCKSZ);
 		return true;
 	}
 
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 75551f60cb..1fd2e20ece 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -459,7 +459,7 @@ MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid,
 	proc = &ProcGlobal->allProcs[gxact->pgprocno];
 
 	/* Initialize the PGPROC entry */
-	MemSet(proc, 0, sizeof(PGPROC));
+	memset(proc, 0, sizeof(PGPROC));
 	proc->pgprocno = gxact->pgprocno;
 	SHMQueueElemInit(&(proc->links));
 	proc->waitStatus = PROC_WAIT_STATUS_OK;
@@ -791,8 +791,8 @@ pg_prepared_xact(PG_FUNCTION_ARGS)
 		/*
 		 * Form tuple with appropriate data.
 		 */
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, 0, sizeof(nulls));
+		memset(values, 0, sizeof(values));
+		memset(nulls, 0, sizeof(nulls));
 
 		values[0] = TransactionIdGetDatum(proc->xid);
 		values[1] = CStringGetTextDatum(gxact->gid);
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 71136b11a2..46a24d5a73 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -1280,7 +1280,7 @@ CopyXLogRecordToWAL(int write_len, bool isLogSwitch, XLogRecData *rdata,
 			 * and zero most of the page.  Then we just zero the page header.
 			 */
 			currpos = GetXLogBuffer(CurrPos, tli);
-			MemSet(currpos, 0, SizeOfXLogShortPHD);
+			memset(currpos, 0, SizeOfXLogShortPHD);
 
 			CurrPos += XLOG_BLCKSZ;
 		}
@@ -1868,7 +1868,7 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, TimeLineID tli, bool opportunistic)
 		 * Be sure to re-zero the buffer so that bytes beyond what we've
 		 * written will look like zeroes and not valid XLOG records...
 		 */
-		MemSet((char *) NewPage, 0, XLOG_BLCKSZ);
+		memset((char *) NewPage, 0, XLOG_BLCKSZ);
 
 		/*
 		 * Fill the new page's header
@@ -6302,7 +6302,7 @@ CreateCheckPoint(int flags)
 	 * checkpoint proceeds, we always accumulate stats, even if
 	 * log_checkpoints is currently off.
 	 */
-	MemSet(&CheckpointStats, 0, sizeof(CheckpointStats));
+	memset(&CheckpointStats, 0, sizeof(CheckpointStats));
 	CheckpointStats.ckpt_start_t = GetCurrentTimestamp();
 
 	/*
@@ -6327,7 +6327,7 @@ CreateCheckPoint(int flags)
 	}
 
 	/* Begin filling in the checkpoint WAL record */
-	MemSet(&checkPoint, 0, sizeof(checkPoint));
+	memset(&checkPoint, 0, sizeof(checkPoint));
 	checkPoint.time = (pg_time_t) time(NULL);
 
 	/*
@@ -6999,7 +6999,7 @@ CreateRestartPoint(int flags)
 	 * checkpoint proceeds, we always accumulate stats, even if
 	 * log_checkpoints is currently off.
 	 */
-	MemSet(&CheckpointStats, 0, sizeof(CheckpointStats));
+	memset(&CheckpointStats, 0, sizeof(CheckpointStats));
 	CheckpointStats.ckpt_start_t = GetCurrentTimestamp();
 
 	if (log_checkpoints)
diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c
index 02bd919ff6..7bc2fa360a 100644
--- a/src/backend/access/transam/xlogfuncs.c
+++ b/src/backend/access/transam/xlogfuncs.c
@@ -117,8 +117,8 @@ pg_backup_stop(PG_FUNCTION_ARGS)
 	if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
 		elog(ERROR, "return type must be a row type");
 
-	MemSet(values, 0, sizeof(values));
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(values, 0, sizeof(values));
+	memset(nulls, 0, sizeof(nulls));
 
 	if (status != SESSION_BACKUP_RUNNING)
 		ereport(ERROR,
diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c
index 2ce9be2cc7..5255401524 100644
--- a/src/backend/access/transam/xloginsert.c
+++ b/src/backend/access/transam/xloginsert.c
@@ -204,7 +204,7 @@ XLogEnsureRecordSpace(int max_block_id, int ndatas)
 		 * At least the padding bytes in the structs must be zeroed, because
 		 * they are included in WAL data, but initialize it all for tidiness.
 		 */
-		MemSet(&registered_buffers[max_registered_buffers], 0,
+		memset(&registered_buffers[max_registered_buffers], 0,
 			   (nbuffers - max_registered_buffers) * sizeof(registered_buffer));
 		max_registered_buffers = nbuffers;
 	}
diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c
index cf5db23cb8..28dc1e02c5 100644
--- a/src/backend/access/transam/xlogreader.c
+++ b/src/backend/access/transam/xlogreader.c
@@ -2093,7 +2093,7 @@ RestoreBlockImage(XLogReaderState *record, uint8 block_id, char *page)
 	{
 		memcpy(page, ptr, bkpb->hole_offset);
 		/* must zero-fill the hole */
-		MemSet(page + bkpb->hole_offset, 0, bkpb->hole_length);
+		memset(page + bkpb->hole_offset, 0, bkpb->hole_length);
 		memcpy(page + (bkpb->hole_offset + bkpb->hole_length),
 			   ptr + bkpb->hole_offset,
 			   BLCKSZ - (bkpb->hole_offset + bkpb->hole_length));
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 9fa8fdd4cf..9cf2f1348c 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -513,7 +513,7 @@ DefineAttr(char *name, char *type, int attnum, int nullness)
 
 	if (attrtypes[attnum] == NULL)
 		attrtypes[attnum] = AllocateAttribute();
-	MemSet(attrtypes[attnum], 0, ATTRIBUTE_FIXED_PART_SIZE);
+	memset(attrtypes[attnum], 0, ATTRIBUTE_FIXED_PART_SIZE);
 
 	namestrcpy(&attrtypes[attnum]->attname, name);
 	elog(DEBUG4, "column %s %s", NameStr(attrtypes[attnum]->attname), type);
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index 5f1726c095..2bc981ace0 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -1344,9 +1344,9 @@ SetDefaultACL(InternalDefaultACL *iacls)
 		Oid			defAclOid;
 
 		/* Prepare to insert or update pg_default_acl entry */
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, false, sizeof(nulls));
-		MemSet(replaces, false, sizeof(replaces));
+		memset(values, 0, sizeof(values));
+		memset(nulls, false, sizeof(nulls));
+		memset(replaces, false, sizeof(replaces));
 
 		if (isNew)
 		{
@@ -1745,9 +1745,9 @@ ExecGrant_Attribute(InternalGrant *istmt, Oid relOid, const char *relname,
 	nnewmembers = aclmembers(new_acl, &newmembers);
 
 	/* finished building new ACL value, now insert it */
-	MemSet(values, 0, sizeof(values));
-	MemSet(nulls, false, sizeof(nulls));
-	MemSet(replaces, false, sizeof(replaces));
+	memset(values, 0, sizeof(values));
+	memset(nulls, false, sizeof(nulls));
+	memset(replaces, false, sizeof(replaces));
 
 	/*
 	 * If the updated ACL is empty, we can set attacl to null, and maybe even
@@ -2027,9 +2027,9 @@ ExecGrant_Relation(InternalGrant *istmt)
 			nnewmembers = aclmembers(new_acl, &newmembers);
 
 			/* finished building new ACL value, now insert it */
-			MemSet(values, 0, sizeof(values));
-			MemSet(nulls, false, sizeof(nulls));
-			MemSet(replaces, false, sizeof(replaces));
+			memset(values, 0, sizeof(values));
+			memset(nulls, false, sizeof(nulls));
+			memset(replaces, false, sizeof(replaces));
 
 			replaces[Anum_pg_class_relacl - 1] = true;
 			values[Anum_pg_class_relacl - 1] = PointerGetDatum(new_acl);
@@ -2217,9 +2217,9 @@ ExecGrant_Database(InternalGrant *istmt)
 		nnewmembers = aclmembers(new_acl, &newmembers);
 
 		/* finished building new ACL value, now insert it */
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, false, sizeof(nulls));
-		MemSet(replaces, false, sizeof(replaces));
+		memset(values, 0, sizeof(values));
+		memset(nulls, false, sizeof(nulls));
+		memset(replaces, false, sizeof(replaces));
 
 		replaces[Anum_pg_database_datacl - 1] = true;
 		values[Anum_pg_database_datacl - 1] = PointerGetDatum(new_acl);
@@ -2339,9 +2339,9 @@ ExecGrant_Fdw(InternalGrant *istmt)
 		nnewmembers = aclmembers(new_acl, &newmembers);
 
 		/* finished building new ACL value, now insert it */
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, false, sizeof(nulls));
-		MemSet(replaces, false, sizeof(replaces));
+		memset(values, 0, sizeof(values));
+		memset(nulls, false, sizeof(nulls));
+		memset(replaces, false, sizeof(replaces));
 
 		replaces[Anum_pg_foreign_data_wrapper_fdwacl - 1] = true;
 		values[Anum_pg_foreign_data_wrapper_fdwacl - 1] = PointerGetDatum(new_acl);
@@ -2465,9 +2465,9 @@ ExecGrant_ForeignServer(InternalGrant *istmt)
 		nnewmembers = aclmembers(new_acl, &newmembers);
 
 		/* finished building new ACL value, now insert it */
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, false, sizeof(nulls));
-		MemSet(replaces, false, sizeof(replaces));
+		memset(values, 0, sizeof(values));
+		memset(nulls, false, sizeof(nulls));
+		memset(replaces, false, sizeof(replaces));
 
 		replaces[Anum_pg_foreign_server_srvacl - 1] = true;
 		values[Anum_pg_foreign_server_srvacl - 1] = PointerGetDatum(new_acl);
@@ -2589,9 +2589,9 @@ ExecGrant_Function(InternalGrant *istmt)
 		nnewmembers = aclmembers(new_acl, &newmembers);
 
 		/* finished building new ACL value, now insert it */
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, false, sizeof(nulls));
-		MemSet(replaces, false, sizeof(replaces));
+		memset(values, 0, sizeof(values));
+		memset(nulls, false, sizeof(nulls));
+		memset(replaces, false, sizeof(replaces));
 
 		replaces[Anum_pg_proc_proacl - 1] = true;
 		values[Anum_pg_proc_proacl - 1] = PointerGetDatum(new_acl);
@@ -2720,9 +2720,9 @@ ExecGrant_Language(InternalGrant *istmt)
 		nnewmembers = aclmembers(new_acl, &newmembers);
 
 		/* finished building new ACL value, now insert it */
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, false, sizeof(nulls));
-		MemSet(replaces, false, sizeof(replaces));
+		memset(values, 0, sizeof(values));
+		memset(nulls, false, sizeof(nulls));
+		memset(replaces, false, sizeof(replaces));
 
 		replaces[Anum_pg_language_lanacl - 1] = true;
 		values[Anum_pg_language_lanacl - 1] = PointerGetDatum(new_acl);
@@ -2858,9 +2858,9 @@ ExecGrant_Largeobject(InternalGrant *istmt)
 		nnewmembers = aclmembers(new_acl, &newmembers);
 
 		/* finished building new ACL value, now insert it */
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, false, sizeof(nulls));
-		MemSet(replaces, false, sizeof(replaces));
+		memset(values, 0, sizeof(values));
+		memset(nulls, false, sizeof(nulls));
+		memset(replaces, false, sizeof(replaces));
 
 		replaces[Anum_pg_largeobject_metadata_lomacl - 1] = true;
 		values[Anum_pg_largeobject_metadata_lomacl - 1]
@@ -2984,9 +2984,9 @@ ExecGrant_Namespace(InternalGrant *istmt)
 		nnewmembers = aclmembers(new_acl, &newmembers);
 
 		/* finished building new ACL value, now insert it */
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, false, sizeof(nulls));
-		MemSet(replaces, false, sizeof(replaces));
+		memset(values, 0, sizeof(values));
+		memset(nulls, false, sizeof(nulls));
+		memset(replaces, false, sizeof(replaces));
 
 		replaces[Anum_pg_namespace_nspacl - 1] = true;
 		values[Anum_pg_namespace_nspacl - 1] = PointerGetDatum(new_acl);
@@ -3108,9 +3108,9 @@ ExecGrant_Tablespace(InternalGrant *istmt)
 		nnewmembers = aclmembers(new_acl, &newmembers);
 
 		/* finished building new ACL value, now insert it */
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, false, sizeof(nulls));
-		MemSet(replaces, false, sizeof(replaces));
+		memset(values, 0, sizeof(values));
+		memset(nulls, false, sizeof(nulls));
+		memset(replaces, false, sizeof(replaces));
 
 		replaces[Anum_pg_tablespace_spcacl - 1] = true;
 		values[Anum_pg_tablespace_spcacl - 1] = PointerGetDatum(new_acl);
@@ -3242,9 +3242,9 @@ ExecGrant_Type(InternalGrant *istmt)
 		nnewmembers = aclmembers(new_acl, &newmembers);
 
 		/* finished building new ACL value, now insert it */
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, false, sizeof(nulls));
-		MemSet(replaces, false, sizeof(replaces));
+		memset(values, 0, sizeof(values));
+		memset(nulls, false, sizeof(nulls));
+		memset(replaces, false, sizeof(replaces));
 
 		replaces[Anum_pg_type_typacl - 1] = true;
 		values[Anum_pg_type_typacl - 1] = PointerGetDatum(new_acl);
@@ -3388,9 +3388,9 @@ ExecGrant_Parameter(InternalGrant *istmt)
 			bool		nulls[Natts_pg_parameter_acl];
 			bool		replaces[Natts_pg_parameter_acl];
 
-			MemSet(values, 0, sizeof(values));
-			MemSet(nulls, false, sizeof(nulls));
-			MemSet(replaces, false, sizeof(replaces));
+			memset(values, 0, sizeof(values));
+			memset(nulls, false, sizeof(nulls));
+			memset(replaces, false, sizeof(replaces));
 
 			replaces[Anum_pg_parameter_acl_paracl - 1] = true;
 			values[Anum_pg_parameter_acl_paracl - 1] = PointerGetDatum(new_acl);
@@ -6426,9 +6426,9 @@ recordExtensionInitPrivWorker(Oid objoid, Oid classoid, int objsubid, Acl *new_a
 		/* If we have a new ACL to set, then update the row with it. */
 		if (new_acl)
 		{
-			MemSet(values, 0, sizeof(values));
-			MemSet(nulls, false, sizeof(nulls));
-			MemSet(replace, false, sizeof(replace));
+			memset(values, 0, sizeof(values));
+			memset(nulls, false, sizeof(nulls));
+			memset(replace, false, sizeof(replace));
 
 			values[Anum_pg_init_privs_initprivs - 1] = PointerGetDatum(new_acl);
 			replace[Anum_pg_init_privs_initprivs - 1] = true;
@@ -6458,7 +6458,7 @@ recordExtensionInitPrivWorker(Oid objoid, Oid classoid, int objsubid, Acl *new_a
 		if (new_acl)
 		{
 			/* No entry found, so add it. */
-			MemSet(nulls, false, sizeof(nulls));
+			memset(nulls, false, sizeof(nulls));
 
 			values[Anum_pg_init_privs_objoid - 1] = ObjectIdGetDatum(objoid);
 			values[Anum_pg_init_privs_classoid - 1] = ObjectIdGetDatum(classoid);
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index de10923391..e853de5bac 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -1640,7 +1640,7 @@ recordDependencyOnSingleRelExpr(const ObjectAddress *depender,
 	context.addrs = new_object_addresses();
 
 	/* We gin up a rather bogus rangetable list to handle Vars */
-	MemSet(&rte, 0, sizeof(rte));
+	memset(&rte, 0, sizeof(rte));
 	rte.type = T_RangeTblEntry;
 	rte.rtekind = RTE_RELATION;
 	rte.relid = relId;
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 1803194db9..75c0610e46 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -1714,9 +1714,9 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
 			bool		replacesAtt[Natts_pg_attribute];
 
 			/* update the tuple - set atthasmissing and attmissingval */
-			MemSet(valuesAtt, 0, sizeof(valuesAtt));
-			MemSet(nullsAtt, false, sizeof(nullsAtt));
-			MemSet(replacesAtt, false, sizeof(replacesAtt));
+			memset(valuesAtt, 0, sizeof(valuesAtt));
+			memset(nullsAtt, false, sizeof(nullsAtt));
+			memset(replacesAtt, false, sizeof(replacesAtt));
 
 			valuesAtt[Anum_pg_attribute_atthasmissing - 1] =
 				BoolGetDatum(false);
@@ -2041,9 +2041,9 @@ SetAttrMissing(Oid relid, char *attname, char *value)
 								  Int32GetDatum(attStruct->atttypmod));
 
 	/* update the tuple - set atthasmissing and attmissingval */
-	MemSet(valuesAtt, 0, sizeof(valuesAtt));
-	MemSet(nullsAtt, false, sizeof(nullsAtt));
-	MemSet(replacesAtt, false, sizeof(replacesAtt));
+	memset(valuesAtt, 0, sizeof(valuesAtt));
+	memset(nullsAtt, false, sizeof(nullsAtt));
+	memset(replacesAtt, false, sizeof(replacesAtt));
 
 	valuesAtt[Anum_pg_attribute_atthasmissing - 1] = BoolGetDatum(true);
 	replacesAtt[Anum_pg_attribute_atthasmissing - 1] = true;
@@ -3347,7 +3347,7 @@ StorePartitionKey(Relation rel,
 
 	pg_partitioned_table = table_open(PartitionedRelationId, RowExclusiveLock);
 
-	MemSet(nulls, false, sizeof(nulls));
+	memset(nulls, false, sizeof(nulls));
 
 	/* Only this can ever be NULL */
 	if (!partexprDatum)
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index bdd3c34841..99d176846c 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -309,7 +309,7 @@ ConstructTupleDescriptor(Relation heapRelation,
 		Form_pg_opclass opclassTup;
 		Oid			keyType;
 
-		MemSet(to, 0, ATTRIBUTE_FIXED_PART_SIZE);
+		memset(to, 0, ATTRIBUTE_FIXED_PART_SIZE);
 		to->attnum = i + 1;
 		to->attstattarget = -1;
 		to->attcacheoff = -1;
@@ -607,7 +607,7 @@ UpdateIndexRelation(Oid indexoid,
 	/*
 	 * Build a pg_index tuple
 	 */
-	MemSet(nulls, false, sizeof(nulls));
+	memset(nulls, false, sizeof(nulls));
 
 	values[Anum_pg_index_indexrelid - 1] = ObjectIdGetDatum(indexoid);
 	values[Anum_pg_index_indrelid - 1] = ObjectIdGetDatum(heapoid);
diff --git a/src/backend/catalog/pg_attrdef.c b/src/backend/catalog/pg_attrdef.c
index c5d4a9912e..11c61f4970 100644
--- a/src/backend/catalog/pg_attrdef.c
+++ b/src/backend/catalog/pg_attrdef.c
@@ -117,9 +117,9 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
 		Datum		missingval = (Datum) 0;
 		bool		missingIsNull = true;
 
-		MemSet(valuesAtt, 0, sizeof(valuesAtt));
-		MemSet(nullsAtt, false, sizeof(nullsAtt));
-		MemSet(replacesAtt, false, sizeof(replacesAtt));
+		memset(valuesAtt, 0, sizeof(valuesAtt));
+		memset(nullsAtt, false, sizeof(nullsAtt));
+		memset(replacesAtt, false, sizeof(replacesAtt));
 		valuesAtt[Anum_pg_attribute_atthasdef - 1] = true;
 		replacesAtt[Anum_pg_attribute_atthasdef - 1] = true;
 
diff --git a/src/backend/catalog/pg_cast.c b/src/backend/catalog/pg_cast.c
index 4857f6468d..cbf49817cf 100644
--- a/src/backend/catalog/pg_cast.c
+++ b/src/backend/catalog/pg_cast.c
@@ -78,7 +78,7 @@ CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, char castcontext,
 	values[Anum_pg_cast_castcontext - 1] = CharGetDatum(castcontext);
 	values[Anum_pg_cast_castmethod - 1] = CharGetDatum(castmethod);
 
-	MemSet(nulls, false, sizeof(nulls));
+	memset(nulls, false, sizeof(nulls));
 
 	tuple = heap_form_tuple(RelationGetDescr(relation), values, nulls);
 
diff --git a/src/backend/catalog/pg_parameter_acl.c b/src/backend/catalog/pg_parameter_acl.c
index 2decee909b..4afeb7218c 100644
--- a/src/backend/catalog/pg_parameter_acl.c
+++ b/src/backend/catalog/pg_parameter_acl.c
@@ -98,8 +98,8 @@ ParameterAclCreate(const char *parameter)
 	 */
 	rel = table_open(ParameterAclRelationId, RowExclusiveLock);
 	tupDesc = RelationGetDescr(rel);
-	MemSet(values, 0, sizeof(values));
-	MemSet(nulls, false, sizeof(nulls));
+	memset(values, 0, sizeof(values));
+	memset(nulls, false, sizeof(nulls));
 	parameterId = GetNewOidWithIndex(rel,
 									 ParameterAclOidIndexId,
 									 Anum_pg_parameter_acl_oid);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 8c7fca62de..7aa7a019c9 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -1168,8 +1168,8 @@ pg_get_publication_tables(PG_FUNCTION_ARGS)
 		/*
 		 * Form tuple with appropriate data.
 		 */
-		MemSet(nulls, 0, sizeof(nulls));
-		MemSet(values, 0, sizeof(values));
+		memset(nulls, 0, sizeof(nulls));
+		memset(values, 0, sizeof(values));
 
 		publication = GetPublicationByName(pubname, false);
 
diff --git a/src/backend/catalog/storage.c b/src/backend/catalog/storage.c
index c06e414a38..b8ce4749ed 100644
--- a/src/backend/catalog/storage.c
+++ b/src/backend/catalog/storage.c
@@ -613,7 +613,7 @@ SerializePendingSyncs(Size maxSize, char *startAddress)
 	hash_destroy(tmphash);
 
 terminate:
-	MemSet(dest, 0, sizeof(RelFileNode));
+	memset(dest, 0, sizeof(RelFileNode));
 }
 
 /*
diff --git a/src/backend/commands/copyfromparse.c b/src/backend/commands/copyfromparse.c
index edb80e2cd5..b1d07f911d 100644
--- a/src/backend/commands/copyfromparse.c
+++ b/src/backend/commands/copyfromparse.c
@@ -867,8 +867,8 @@ NextCopyFrom(CopyFromState cstate, ExprContext *econtext,
 	attr_count = list_length(cstate->attnumlist);
 
 	/* Initialize all values for row to NULL */
-	MemSet(values, 0, num_phys_attrs * sizeof(Datum));
-	MemSet(nulls, true, num_phys_attrs * sizeof(bool));
+	memset(values, 0, num_phys_attrs * sizeof(Datum));
+	memset(nulls, true, num_phys_attrs * sizeof(bool));
 
 	if (!cstate->opts.binary)
 	{
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index f269168401..70e87ee559 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -1296,8 +1296,8 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
 		   (dblocprovider != COLLPROVIDER_ICU && !dbiculocale));
 
 	/* Form tuple */
-	MemSet(new_record, 0, sizeof(new_record));
-	MemSet(new_record_nulls, false, sizeof(new_record_nulls));
+	memset(new_record, 0, sizeof(new_record));
+	memset(new_record_nulls, false, sizeof(new_record_nulls));
 
 	new_record[Anum_pg_database_oid - 1] = ObjectIdGetDatum(dboid);
 	new_record[Anum_pg_database_datname - 1] =
@@ -2042,9 +2042,9 @@ movedb(const char *dbname, const char *tblspcname)
 					(errcode(ERRCODE_UNDEFINED_DATABASE),
 					 errmsg("database \"%s\" does not exist", dbname)));
 
-		MemSet(new_record, 0, sizeof(new_record));
-		MemSet(new_record_nulls, false, sizeof(new_record_nulls));
-		MemSet(new_record_repl, false, sizeof(new_record_repl));
+		memset(new_record, 0, sizeof(new_record));
+		memset(new_record_nulls, false, sizeof(new_record_nulls));
+		memset(new_record_repl, false, sizeof(new_record_repl));
 
 		new_record[Anum_pg_database_dattablespace - 1] = ObjectIdGetDatum(dst_tblspcoid);
 		new_record_repl[Anum_pg_database_dattablespace - 1] = true;
@@ -2305,9 +2305,9 @@ AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
 	/*
 	 * Build an updated tuple, perusing the information just obtained
 	 */
-	MemSet(new_record, 0, sizeof(new_record));
-	MemSet(new_record_nulls, false, sizeof(new_record_nulls));
-	MemSet(new_record_repl, false, sizeof(new_record_repl));
+	memset(new_record, 0, sizeof(new_record));
+	memset(new_record_nulls, false, sizeof(new_record_nulls));
+	memset(new_record_repl, false, sizeof(new_record_repl));
 
 	if (distemplate)
 	{
diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c
index 4642527881..b927a3f479 100644
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -1316,8 +1316,8 @@ pg_event_trigger_dropped_objects(PG_FUNCTION_ARGS)
 
 		obj = slist_container(SQLDropObject, next, iter.cur);
 
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, 0, sizeof(nulls));
+		memset(values, 0, sizeof(values));
+		memset(nulls, 0, sizeof(nulls));
 
 		/* classid */
 		values[i++] = ObjectIdGetDatum(obj->address.classId);
@@ -1859,7 +1859,7 @@ pg_event_trigger_ddl_commands(PG_FUNCTION_ARGS)
 			!OidIsValid(cmd->d.simple.address.objectId))
 			continue;
 
-		MemSet(nulls, 0, sizeof(nulls));
+		memset(nulls, 0, sizeof(nulls));
 
 		switch (cmd->type)
 		{
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index 00a6d282cf..b14cc774c0 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -1917,7 +1917,7 @@ CreateTransform(CreateTransformStmt *stmt)
 	values[Anum_pg_transform_trffromsql - 1] = ObjectIdGetDatum(fromsqlfuncid);
 	values[Anum_pg_transform_trftosql - 1] = ObjectIdGetDatum(tosqlfuncid);
 
-	MemSet(nulls, false, sizeof(nulls));
+	memset(nulls, false, sizeof(nulls));
 
 	relation = table_open(TransformRelationId, RowExclusiveLock);
 
@@ -1935,7 +1935,7 @@ CreateTransform(CreateTransformStmt *stmt)
 							format_type_be(typeid),
 							stmt->lang)));
 
-		MemSet(replaces, false, sizeof(replaces));
+		memset(replaces, false, sizeof(replaces));
 		replaces[Anum_pg_transform_trffromsql - 1] = true;
 		replaces[Anum_pg_transform_trftosql - 1] = true;
 
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index 80738547ed..eeb77991b0 100644
--- a/src/backend/commands/prepare.c
+++ b/src/backend/commands/prepare.c
@@ -686,7 +686,7 @@ pg_prepared_statement(PG_FUNCTION_ARGS)
 			Datum		values[7];
 			bool		nulls[7];
 
-			MemSet(nulls, 0, sizeof(nulls));
+			memset(nulls, 0, sizeof(nulls));
 
 			values[0] = CStringGetTextDatum(prep_stmt->stmt_name);
 			values[1] = CStringGetTextDatum(prep_stmt->plansource->query_string);
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 2de0ebacec..1f180306c2 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -9112,15 +9112,15 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
 	 * Look up the referencing attributes to make sure they exist, and record
 	 * their attnums and type OIDs.
 	 */
-	MemSet(pkattnum, 0, sizeof(pkattnum));
-	MemSet(fkattnum, 0, sizeof(fkattnum));
-	MemSet(pktypoid, 0, sizeof(pktypoid));
-	MemSet(fktypoid, 0, sizeof(fktypoid));
-	MemSet(opclasses, 0, sizeof(opclasses));
-	MemSet(pfeqoperators, 0, sizeof(pfeqoperators));
-	MemSet(ppeqoperators, 0, sizeof(ppeqoperators));
-	MemSet(ffeqoperators, 0, sizeof(ffeqoperators));
-	MemSet(fkdelsetcols, 0, sizeof(fkdelsetcols));
+	memset(pkattnum, 0, sizeof(pkattnum));
+	memset(fkattnum, 0, sizeof(fkattnum));
+	memset(pktypoid, 0, sizeof(pktypoid));
+	memset(fktypoid, 0, sizeof(fktypoid));
+	memset(opclasses, 0, sizeof(opclasses));
+	memset(pfeqoperators, 0, sizeof(pfeqoperators));
+	memset(ppeqoperators, 0, sizeof(ppeqoperators));
+	memset(ffeqoperators, 0, sizeof(ffeqoperators));
+	memset(fkdelsetcols, 0, sizeof(fkdelsetcols));
 
 	numfks = transformColumnNameList(RelationGetRelid(rel),
 									 fkconstraint->fk_attrs,
@@ -11508,7 +11508,7 @@ validateForeignKeyConstraint(char *conname,
 	/*
 	 * Build a trigger call structure; we'll need it either way.
 	 */
-	MemSet(&trig, 0, sizeof(trig));
+	memset(&trig, 0, sizeof(trig));
 	trig.tgoid = InvalidOid;
 	trig.tgname = conname;
 	trig.tgenabled = TRIGGER_FIRES_ON_ORIGIN;
@@ -11553,7 +11553,7 @@ validateForeignKeyConstraint(char *conname,
 		 *
 		 * No parameters are passed, but we do set a context
 		 */
-		MemSet(fcinfo, 0, SizeForFunctionCallInfo(0));
+		memset(fcinfo, 0, SizeForFunctionCallInfo(0));
 
 		/*
 		 * We assume RI_FKey_check_ins won't look at flinfo...
@@ -12787,9 +12787,9 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
 			bool		replacesAtt[Natts_pg_attribute];
 			HeapTuple	newTup;
 
-			MemSet(valuesAtt, 0, sizeof(valuesAtt));
-			MemSet(nullsAtt, false, sizeof(nullsAtt));
-			MemSet(replacesAtt, false, sizeof(replacesAtt));
+			memset(valuesAtt, 0, sizeof(valuesAtt));
+			memset(nullsAtt, false, sizeof(nullsAtt));
+			memset(replacesAtt, false, sizeof(replacesAtt));
 
 			missingval = array_get_element(missingval,
 										   1,
@@ -19231,7 +19231,7 @@ ATDetachCheckNoForeignKeyRefs(Relation partition)
 		/* prevent data changes into the referencing table until commit */
 		rel = table_open(constrForm->conrelid, ShareLock);
 
-		MemSet(&trig, 0, sizeof(trig));
+		memset(&trig, 0, sizeof(trig));
 		trig.tgoid = InvalidOid;
 		trig.tgname = NameStr(constrForm->conname);
 		trig.tgenabled = TRIGGER_FIRES_ON_ORIGIN;
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index 00ca397fe8..b55f07f092 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -340,7 +340,7 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
 	 */
 	rel = table_open(TableSpaceRelationId, RowExclusiveLock);
 
-	MemSet(nulls, false, sizeof(nulls));
+	memset(nulls, false, sizeof(nulls));
 
 	if (IsBinaryUpgrade)
 	{
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index 9b92b04242..5b91f14a7e 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -2596,9 +2596,9 @@ AlterDomainDefault(List *names, Node *defaultRaw)
 	checkDomainOwner(tup);
 
 	/* Setup new tuple */
-	MemSet(new_record, (Datum) 0, sizeof(new_record));
-	MemSet(new_record_nulls, false, sizeof(new_record_nulls));
-	MemSet(new_record_repl, false, sizeof(new_record_repl));
+	memset(new_record, (Datum) 0, sizeof(new_record));
+	memset(new_record_nulls, false, sizeof(new_record_nulls));
+	memset(new_record_repl, false, sizeof(new_record_repl));
 
 	/* Store the new default into the tuple */
 	if (defaultRaw)
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 984305ba31..61a28e2098 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -338,8 +338,8 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt)
 	/*
 	 * Build a tuple to insert
 	 */
-	MemSet(new_record, 0, sizeof(new_record));
-	MemSet(new_record_nulls, false, sizeof(new_record_nulls));
+	memset(new_record, 0, sizeof(new_record));
+	memset(new_record_nulls, false, sizeof(new_record_nulls));
 
 	new_record[Anum_pg_authid_rolname - 1] =
 		DirectFunctionCall1(namein, CStringGetDatum(stmt->role));
@@ -691,9 +691,9 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
 	/*
 	 * Build an updated tuple, perusing the information just obtained
 	 */
-	MemSet(new_record, 0, sizeof(new_record));
-	MemSet(new_record_nulls, false, sizeof(new_record_nulls));
-	MemSet(new_record_repl, false, sizeof(new_record_repl));
+	memset(new_record, 0, sizeof(new_record));
+	memset(new_record_nulls, false, sizeof(new_record_nulls));
+	memset(new_record_repl, false, sizeof(new_record_repl));
 
 	/*
 	 * issuper/createrole/etc
@@ -1500,9 +1500,9 @@ AddRoleMems(const char *rolename, Oid roleid,
 		}
 
 		/* Build a tuple to insert or update */
-		MemSet(new_record, 0, sizeof(new_record));
-		MemSet(new_record_nulls, false, sizeof(new_record_nulls));
-		MemSet(new_record_repl, false, sizeof(new_record_repl));
+		memset(new_record, 0, sizeof(new_record));
+		memset(new_record_nulls, false, sizeof(new_record_nulls));
+		memset(new_record_repl, false, sizeof(new_record_repl));
 
 		new_record[Anum_pg_auth_members_roleid - 1] = ObjectIdGetDatum(roleid);
 		new_record[Anum_pg_auth_members_member - 1] = ObjectIdGetDatum(memberid);
@@ -1619,9 +1619,9 @@ DelRoleMems(const char *rolename, Oid roleid,
 			bool		new_record_repl[Natts_pg_auth_members];
 
 			/* Build a tuple to update with */
-			MemSet(new_record, 0, sizeof(new_record));
-			MemSet(new_record_nulls, false, sizeof(new_record_nulls));
-			MemSet(new_record_repl, false, sizeof(new_record_repl));
+			memset(new_record, 0, sizeof(new_record));
+			memset(new_record_nulls, false, sizeof(new_record_nulls));
+			memset(new_record_repl, false, sizeof(new_record_repl));
 
 			new_record[Anum_pg_auth_members_admin_option - 1] = BoolGetDatum(false);
 			new_record_repl[Anum_pg_auth_members_admin_option - 1] = true;
diff --git a/src/backend/commands/vacuumparallel.c b/src/backend/commands/vacuumparallel.c
index 1753da6c83..6278a97106 100644
--- a/src/backend/commands/vacuumparallel.c
+++ b/src/backend/commands/vacuumparallel.c
@@ -352,7 +352,7 @@ parallel_vacuum_init(Relation rel, Relation *indrels, int nindexes,
 
 	/* Prepare shared information */
 	shared = (PVShared *) shm_toc_allocate(pcxt->toc, est_shared_len);
-	MemSet(shared, 0, est_shared_len);
+	memset(shared, 0, est_shared_len);
 	shared->relid = RelationGetRelid(rel);
 	shared->elevel = elevel;
 	shared->maintenance_work_mem_worker =
@@ -372,7 +372,7 @@ parallel_vacuum_init(Relation rel, Relation *indrels, int nindexes,
 												   est_dead_items_len);
 	dead_items->max_items = max_items;
 	dead_items->num_items = 0;
-	MemSet(dead_items->items, 0, sizeof(ItemPointerData) * max_items);
+	memset(dead_items->items, 0, sizeof(ItemPointerData) * max_items);
 	shm_toc_insert(pcxt->toc, PARALLEL_VACUUM_KEY_DEAD_ITEMS, dead_items);
 	pvs->dead_items = dead_items;
 
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index ef2fd46092..6905edfa9e 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -1198,7 +1198,7 @@ InitResultRelInfo(ResultRelInfo *resultRelInfo,
 				  ResultRelInfo *partition_root_rri,
 				  int instrument_options)
 {
-	MemSet(resultRelInfo, 0, sizeof(ResultRelInfo));
+	memset(resultRelInfo, 0, sizeof(ResultRelInfo));
 	resultRelInfo->type = T_ResultRelInfo;
 	resultRelInfo->ri_RangeTableIndex = resultRelationIndex;
 	resultRelInfo->ri_RelationDesc = resultRelationDesc;
@@ -2735,7 +2735,7 @@ EvalPlanQualBegin(EPQState *epqstate)
 		Index		rtsize = parentestate->es_range_table_size;
 		PlanState  *rcplanstate = epqstate->recheckplanstate;
 
-		MemSet(epqstate->relsubs_done, 0, rtsize * sizeof(bool));
+		memset(epqstate->relsubs_done, 0, rtsize * sizeof(bool));
 
 		/* Recopy current values of parent parameters */
 		if (parentestate->es_plannedstmt->paramExecTypes != NIL)
diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c
index 06ac253ea0..c29309a882 100644
--- a/src/backend/executor/execTuples.c
+++ b/src/backend/executor/execTuples.c
@@ -1587,7 +1587,7 @@ ExecStoreAllNullTuple(TupleTableSlot *slot)
 	/*
 	 * Fill all the columns of the virtual tuple with nulls
 	 */
-	MemSet(slot->tts_values, 0,
+	memset(slot->tts_values, 0,
 		   slot->tts_tupleDescriptor->natts * sizeof(Datum));
 	memset(slot->tts_isnull, true,
 		   slot->tts_tupleDescriptor->natts * sizeof(bool));
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 139b2bd5f9..7768b0168e 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -2599,7 +2599,7 @@ agg_refill_hash_table(AggState *aggstate)
 	 * we rescan later. The expressions for sorted grouping sets will not be
 	 * evaluated after we recompile anyway.
 	 */
-	MemSet(aggstate->hash_pergroup, 0,
+	memset(aggstate->hash_pergroup, 0,
 		   sizeof(AggStatePerGroup) * aggstate->num_hashes);
 
 	/* free memory and reset hash tables */
@@ -4413,8 +4413,8 @@ ExecReScanAgg(AggState *node)
 	ExecClearTuple(node->ss.ss_ScanTupleSlot);
 
 	/* Forget current agg values */
-	MemSet(econtext->ecxt_aggvalues, 0, sizeof(Datum) * node->numaggs);
-	MemSet(econtext->ecxt_aggnulls, 0, sizeof(bool) * node->numaggs);
+	memset(econtext->ecxt_aggvalues, 0, sizeof(Datum) * node->numaggs);
+	memset(econtext->ecxt_aggnulls, 0, sizeof(bool) * node->numaggs);
 
 	/*
 	 * With AGG_HASHED/MIXED, the hash table is allocated in a sub-context of
@@ -4445,7 +4445,7 @@ ExecReScanAgg(AggState *node)
 		 */
 		for (setno = 0; setno < numGroupingSets; setno++)
 		{
-			MemSet(node->pergroups[setno], 0,
+			memset(node->pergroups[setno], 0,
 				   sizeof(AggStatePerGroupData) * node->numaggs);
 		}
 
diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c
index 3510a4247c..f706b7510a 100644
--- a/src/backend/executor/nodeHash.c
+++ b/src/backend/executor/nodeHash.c
@@ -948,9 +948,9 @@ ExecHashIncreaseNumBatches(HashJoinTable hashtable)
 			repalloc(hashtable->innerBatchFile, nbatch * sizeof(BufFile *));
 		hashtable->outerBatchFile = (BufFile **)
 			repalloc(hashtable->outerBatchFile, nbatch * sizeof(BufFile *));
-		MemSet(hashtable->innerBatchFile + oldnbatch, 0,
+		memset(hashtable->innerBatchFile + oldnbatch, 0,
 			   (nbatch - oldnbatch) * sizeof(BufFile *));
-		MemSet(hashtable->outerBatchFile + oldnbatch, 0,
+		memset(hashtable->outerBatchFile + oldnbatch, 0,
 			   (nbatch - oldnbatch) * sizeof(BufFile *));
 	}
 
diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c
index 5ef5c6930f..78774796a0 100644
--- a/src/backend/executor/nodeIndexscan.c
+++ b/src/backend/executor/nodeIndexscan.c
@@ -1437,7 +1437,7 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
 			 * We don't use ScanKeyEntryInitialize for the header because it
 			 * isn't going to contain a valid sk_func pointer.
 			 */
-			MemSet(this_scan_key, 0, sizeof(ScanKeyData));
+			memset(this_scan_key, 0, sizeof(ScanKeyData));
 			this_scan_key->sk_flags = SK_ROW_HEADER;
 			this_scan_key->sk_attno = first_sub_key->sk_attno;
 			this_scan_key->sk_strategy = rc->rctype;
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index 4b104c4d98..510f93f0b7 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -2723,8 +2723,8 @@ ExecReScanWindowAgg(WindowAggState *node)
 		ExecClearTuple(node->frametail_slot);
 
 	/* Forget current wfunc values */
-	MemSet(econtext->ecxt_aggvalues, 0, sizeof(Datum) * node->numfuncs);
-	MemSet(econtext->ecxt_aggnulls, 0, sizeof(bool) * node->numfuncs);
+	memset(econtext->ecxt_aggvalues, 0, sizeof(Datum) * node->numfuncs);
+	memset(econtext->ecxt_aggnulls, 0, sizeof(bool) * node->numfuncs);
 
 	/*
 	 * if chgParam of subnode is not null then plan will be re-scanned by
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index efc53f3135..7c4494c064 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -3041,7 +3041,7 @@ PerformRadiusTransaction(const char *server, const char *secret, const char *por
 	if (identifier == NULL)
 		identifier = "postgresql";
 
-	MemSet(&hint, 0, sizeof(hint));
+	memset(&hint, 0, sizeof(hint));
 	hint.ai_socktype = SOCK_DGRAM;
 	hint.ai_family = AF_UNSPEC;
 	port = atoi(portstr);
diff --git a/src/backend/libpq/be-fsstubs.c b/src/backend/libpq/be-fsstubs.c
index 5804532881..fc4811aa8a 100644
--- a/src/backend/libpq/be-fsstubs.c
+++ b/src/backend/libpq/be-fsstubs.c
@@ -688,7 +688,7 @@ newLOfd(void)
 		newsize = cookies_size * 2;
 		cookies = (LargeObjectDesc **)
 			repalloc(cookies, newsize * sizeof(LargeObjectDesc *));
-		MemSet(cookies + cookies_size, 0,
+		memset(cookies + cookies_size, 0,
 			   (newsize - cookies_size) * sizeof(LargeObjectDesc *));
 		cookies_size = newsize;
 	}
diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c
index 327a4b42af..30fd58e4ca 100644
--- a/src/backend/libpq/hba.c
+++ b/src/backend/libpq/hba.c
@@ -1964,7 +1964,7 @@ parse_hba_auth_opt(char *name, char *val, HbaLine *hbaline,
 		/* For each entry in the list, translate it */
 		foreach(l, parsed_servers)
 		{
-			MemSet(&hints, 0, sizeof(hints));
+			memset(&hints, 0, sizeof(hints));
 			hints.ai_socktype = SOCK_DGRAM;
 			hints.ai_family = AF_UNSPEC;
 
diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index 75392a8bb7..f75304cea1 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -343,7 +343,7 @@ StreamServerPort(int family, const char *hostName, unsigned short portNumber,
 #endif
 
 	/* Initialize hint structure */
-	MemSet(&hint, 0, sizeof(hint));
+	memset(&hint, 0, sizeof(hint));
 	hint.ai_family = family;
 	hint.ai_flags = AI_PASSIVE;
 	hint.ai_socktype = SOCK_STREAM;
diff --git a/src/backend/libpq/pqmq.c b/src/backend/libpq/pqmq.c
index 4d0415e379..139bb90dc5 100644
--- a/src/backend/libpq/pqmq.c
+++ b/src/backend/libpq/pqmq.c
@@ -204,7 +204,7 @@ void
 pq_parse_errornotice(StringInfo msg, ErrorData *edata)
 {
 	/* Initialize edata with reasonable defaults. */
-	MemSet(edata, 0, sizeof(ErrorData));
+	memset(edata, 0, sizeof(ErrorData));
 	edata->elevel = ERROR;
 	edata->assoc_context = CurrentMemoryContext;
 
diff --git a/src/backend/nodes/tidbitmap.c b/src/backend/nodes/tidbitmap.c
index a7a6b26668..dd0260512d 100644
--- a/src/backend/nodes/tidbitmap.c
+++ b/src/backend/nodes/tidbitmap.c
@@ -1230,7 +1230,7 @@ tbm_get_pageentry(TIDBitmap *tbm, BlockNumber pageno)
 	{
 		char		oldstatus = page->status;
 
-		MemSet(page, 0, sizeof(PagetableEntry));
+		memset(page, 0, sizeof(PagetableEntry));
 		page->status = oldstatus;
 		page->blockno = pageno;
 		/* must count it too */
@@ -1317,7 +1317,7 @@ tbm_mark_page_lossy(TIDBitmap *tbm, BlockNumber pageno)
 	{
 		char		oldstatus = page->status;
 
-		MemSet(page, 0, sizeof(PagetableEntry));
+		memset(page, 0, sizeof(PagetableEntry));
 		page->status = oldstatus;
 		page->blockno = chunk_pageno;
 		page->ischunk = true;
@@ -1330,7 +1330,7 @@ tbm_mark_page_lossy(TIDBitmap *tbm, BlockNumber pageno)
 		char		oldstatus = page->status;
 
 		/* chunk header page was formerly non-lossy, make it lossy */
-		MemSet(page, 0, sizeof(PagetableEntry));
+		memset(page, 0, sizeof(PagetableEntry));
 		page->status = oldstatus;
 		page->blockno = chunk_pageno;
 		page->ischunk = true;
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c
index ed98ba7dbd..d2da6e5f0a 100644
--- a/src/backend/optimizer/path/costsize.c
+++ b/src/backend/optimizer/path/costsize.c
@@ -2905,7 +2905,7 @@ cost_agg(Path *path, PlannerInfo *root,
 	if (aggcosts == NULL)
 	{
 		Assert(aggstrategy == AGG_HASHED);
-		MemSet(&dummy_aggcosts, 0, sizeof(AggClauseCosts));
+		memset(&dummy_aggcosts, 0, sizeof(AggClauseCosts));
 		aggcosts = &dummy_aggcosts;
 	}
 
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c
index 0ef70ad7f1..f6c2cd8974 100644
--- a/src/backend/optimizer/path/indxpath.c
+++ b/src/backend/optimizer/path/indxpath.c
@@ -269,7 +269,7 @@ create_index_paths(PlannerInfo *root, RelOptInfo *rel)
 		/*
 		 * Identify the restriction clauses that can match the index.
 		 */
-		MemSet(&rclauseset, 0, sizeof(rclauseset));
+		memset(&rclauseset, 0, sizeof(rclauseset));
 		match_restriction_clauses_to_index(root, index, &rclauseset);
 
 		/*
@@ -286,7 +286,7 @@ create_index_paths(PlannerInfo *root, RelOptInfo *rel)
 		 * step finds only "loose" join clauses that have not been merged into
 		 * EquivalenceClasses.  Also, collect join OR clauses for later.
 		 */
-		MemSet(&jclauseset, 0, sizeof(jclauseset));
+		memset(&jclauseset, 0, sizeof(jclauseset));
 		match_join_clauses_to_index(root, rel, index,
 									&jclauseset, &joinorclauses);
 
@@ -294,7 +294,7 @@ create_index_paths(PlannerInfo *root, RelOptInfo *rel)
 		 * Look for EquivalenceClasses that can generate joinclauses matching
 		 * the index.
 		 */
-		MemSet(&eclauseset, 0, sizeof(eclauseset));
+		memset(&eclauseset, 0, sizeof(eclauseset));
 		match_eclass_clauses_to_index(root, index,
 									  &eclauseset);
 
@@ -616,7 +616,7 @@ get_join_index_paths(PlannerInfo *root, RelOptInfo *rel,
 		return;
 
 	/* Identify indexclauses usable with this relids set */
-	MemSet(&clauseset, 0, sizeof(clauseset));
+	memset(&clauseset, 0, sizeof(clauseset));
 
 	for (indexcol = 0; indexcol < index->nkeycolumns; indexcol++)
 	{
@@ -1211,7 +1211,7 @@ build_paths_for_OR(PlannerInfo *root, RelOptInfo *rel,
 		/*
 		 * Identify the restriction clauses that can match the index.
 		 */
-		MemSet(&clauseset, 0, sizeof(clauseset));
+		memset(&clauseset, 0, sizeof(clauseset));
 		match_clauses_to_index(root, clauses, index, &clauseset);
 
 		/*
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index a0f2390334..340e902a15 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -3352,7 +3352,7 @@ create_grouping_paths(PlannerInfo *root,
 	RelOptInfo *partially_grouped_rel;
 	AggClauseCosts agg_costs;
 
-	MemSet(&agg_costs, 0, sizeof(AggClauseCosts));
+	memset(&agg_costs, 0, sizeof(AggClauseCosts));
 	get_agg_clause_costs(root, AGGSPLIT_SIMPLE, &agg_costs);
 
 	/*
@@ -5915,12 +5915,12 @@ expression_planner_with_deps(Expr *expr,
 	PlannerInfo root;
 
 	/* Make up dummy planner state so we can use setrefs machinery */
-	MemSet(&glob, 0, sizeof(glob));
+	memset(&glob, 0, sizeof(glob));
 	glob.type = T_PlannerGlobal;
 	glob.relationOids = NIL;
 	glob.invalItems = NIL;
 
-	MemSet(&root, 0, sizeof(root));
+	memset(&root, 0, sizeof(root));
 	root.type = T_PlannerInfo;
 	root.glob = &glob;
 
@@ -6688,8 +6688,8 @@ create_partial_grouping_paths(PlannerInfo *root,
 		 * Collect statistics about aggregates for estimating costs of
 		 * performing aggregation in parallel.
 		 */
-		MemSet(agg_partial_costs, 0, sizeof(AggClauseCosts));
-		MemSet(agg_final_costs, 0, sizeof(AggClauseCosts));
+		memset(agg_partial_costs, 0, sizeof(AggClauseCosts));
+		memset(agg_final_costs, 0, sizeof(AggClauseCosts));
 		if (parse->hasAggs)
 		{
 			/* partial phase */
diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c
index d95fd89807..3cb86fdba0 100644
--- a/src/backend/optimizer/plan/setrefs.c
+++ b/src/backend/optimizer/plan/setrefs.c
@@ -3274,14 +3274,14 @@ extract_query_dependencies(Node *query,
 	PlannerInfo root;
 
 	/* Make up dummy planner state so we can use this module's machinery */
-	MemSet(&glob, 0, sizeof(glob));
+	memset(&glob, 0, sizeof(glob));
 	glob.type = T_PlannerGlobal;
 	glob.relationOids = NIL;
 	glob.invalItems = NIL;
 	/* Hack: we use glob.dependsOnRole to collect hasRowSecurity flags */
 	glob.dependsOnRole = false;
 
-	MemSet(&root, 0, sizeof(root));
+	memset(&root, 0, sizeof(root));
 	root.type = T_PlannerInfo;
 	root.glob = &glob;
 
diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c
index 520409f4ba..9ebe594fcb 100644
--- a/src/backend/optimizer/util/relnode.c
+++ b/src/backend/optimizer/util/relnode.c
@@ -160,13 +160,13 @@ expand_planner_arrays(PlannerInfo *root, int add_size)
 	root->simple_rel_array = (RelOptInfo **)
 		repalloc(root->simple_rel_array,
 				 sizeof(RelOptInfo *) * new_size);
-	MemSet(root->simple_rel_array + root->simple_rel_array_size,
+	memset(root->simple_rel_array + root->simple_rel_array_size,
 		   0, sizeof(RelOptInfo *) * add_size);
 
 	root->simple_rte_array = (RangeTblEntry **)
 		repalloc(root->simple_rte_array,
 				 sizeof(RangeTblEntry *) * new_size);
-	MemSet(root->simple_rte_array + root->simple_rel_array_size,
+	memset(root->simple_rte_array + root->simple_rel_array_size,
 		   0, sizeof(RangeTblEntry *) * add_size);
 
 	if (root->append_rel_array)
@@ -174,7 +174,7 @@ expand_planner_arrays(PlannerInfo *root, int add_size)
 		root->append_rel_array = (AppendRelInfo **)
 			repalloc(root->append_rel_array,
 					 sizeof(AppendRelInfo *) * new_size);
-		MemSet(root->append_rel_array + root->simple_rel_array_size,
+		memset(root->append_rel_array + root->simple_rel_array_size,
 			   0, sizeof(AppendRelInfo *) * add_size);
 	}
 	else
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index cf64afbd85..084d45e7e1 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -958,7 +958,7 @@ make_oper_cache_key(ParseState *pstate, OprCacheKey *key, List *opname,
 	DeconstructQualifiedName(opname, &schemaname, &opername);
 
 	/* ensure zero-fill for stable hashing */
-	MemSet(key, 0, sizeof(OprCacheKey));
+	memset(key, 0, sizeof(OprCacheKey));
 
 	/* save operator name and input types into key */
 	strlcpy(key->oprname, opername, NAMEDATALEN);
diff --git a/src/backend/parser/parse_param.c b/src/backend/parser/parse_param.c
index f668abfcb3..03f022d6c9 100644
--- a/src/backend/parser/parse_param.c
+++ b/src/backend/parser/parse_param.c
@@ -150,7 +150,7 @@ variable_paramref_hook(ParseState *pstate, ParamRef *pref)
 		else
 			*parstate->paramTypes = (Oid *) palloc(paramno * sizeof(Oid));
 		/* Zero out the previously-unreferenced slots */
-		MemSet(*parstate->paramTypes + *parstate->numParams,
+		memset(*parstate->paramTypes + *parstate->numParams,
 			   0,
 			   (paramno - *parstate->numParams) * sizeof(Oid));
 		*parstate->numParams = paramno;
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c
index 2a1d44b813..cb3b64afde 100644
--- a/src/backend/parser/parse_target.c
+++ b/src/backend/parser/parse_target.c
@@ -1596,7 +1596,7 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
 					 */
 					ParseState	mypstate;
 
-					MemSet(&mypstate, 0, sizeof(mypstate));
+					memset(&mypstate, 0, sizeof(mypstate));
 					mypstate.parentParseState = pstate;
 					mypstate.p_rtable = rte->subquery->rtable;
 					/* don't bother filling the rest of the fake pstate */
@@ -1652,7 +1652,7 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
 					ParseState	mypstate;
 					Index		levelsup;
 
-					MemSet(&mypstate, 0, sizeof(mypstate));
+					memset(&mypstate, 0, sizeof(mypstate));
 					/* this loop must work, since GetCTEForRTE did */
 					for (levelsup = 0;
 						 levelsup < rte->ctelevelsup + netlevelsup;
diff --git a/src/backend/port/win32/timer.c b/src/backend/port/win32/timer.c
index 3405253af3..67a434ab9e 100644
--- a/src/backend/port/win32/timer.c
+++ b/src/backend/port/win32/timer.c
@@ -98,7 +98,7 @@ setitimer(int which, const struct itimerval *value, struct itimerval *ovalue)
 					(errmsg_internal("could not create timer event: error code %lu",
 									 GetLastError())));
 
-		MemSet(&timerCommArea.value, 0, sizeof(struct itimerval));
+		memset(&timerCommArea.value, 0, sizeof(struct itimerval));
 
 		InitializeCriticalSection(&timerCommArea.crit_sec);
 
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index c937c39f50..02b1d2533e 100644
--- a/src/backend/postmaster/checkpointer.c
+++ b/src/backend/postmaster/checkpointer.c
@@ -902,7 +902,7 @@ CheckpointerShmemInit(void)
 		 * requests array; this is so that CompactCheckpointerRequestQueue can
 		 * assume that any pad bytes in the request structs are zeroes.
 		 */
-		MemSet(CheckpointerShmem, 0, size);
+		memset(CheckpointerShmem, 0, size);
 		SpinLockInit(&CheckpointerShmem->ckpt_lck);
 		CheckpointerShmem->max_requests = NBuffers;
 		ConditionVariableInit(&CheckpointerShmem->start_cv);
diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c
index 25e31c42e1..bd673df1b0 100644
--- a/src/backend/postmaster/pgarch.c
+++ b/src/backend/postmaster/pgarch.c
@@ -169,7 +169,7 @@ PgArchShmemInit(void)
 	if (!found)
 	{
 		/* First time through, so initialize */
-		MemSet(PgArch, 0, PgArchShmemSize());
+		memset(PgArch, 0, PgArchShmemSize());
 		PgArch->pgprocno = INVALID_PGPROCNO;
 		SpinLockInit(&PgArch->arch_lck);
 	}
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index 5244823ff8..ce53e628b6 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -688,7 +688,7 @@ parse_basebackup_options(List *options, basebackup_options *opt)
 	bool		o_compression_detail = false;
 	char	   *compression_detail_str = NULL;
 
-	MemSet(opt, 0, sizeof(*opt));
+	memset(opt, 0, sizeof(*opt));
 	opt->manifest = MANIFEST_OPTION_NO;
 	opt->manifest_checksum_type = CHECKSUM_TYPE_CRC32C;
 	opt->compression = PG_COMPRESSION_NONE;
@@ -1687,7 +1687,7 @@ sendFile(bbsink *sink, const char *readfilename, const char *tarfilename,
 		size_t		remaining = statbuf->st_size - len;
 		size_t		nbytes = Min(sink->bbs_buffer_length, remaining);
 
-		MemSet(sink->bbs_buffer, 0, nbytes);
+		memset(sink->bbs_buffer, 0, nbytes);
 		if (pg_checksum_update(&checksum_ctx,
 							   (uint8 *) sink->bbs_buffer,
 							   nbytes) < 0)
@@ -1790,7 +1790,7 @@ _tarWritePadding(bbsink *sink, int len)
 
 	if (pad > 0)
 	{
-		MemSet(sink->bbs_buffer, 0, pad);
+		memset(sink->bbs_buffer, 0, pad);
 		bbsink_archive_contents(sink, pad);
 	}
 }
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index bd5f78cf9a..4c4ad80f9a 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -953,8 +953,8 @@ pg_stat_get_subscription(PG_FUNCTION_ARGS)
 
 		worker_pid = worker.proc->pid;
 
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, 0, sizeof(nulls));
+		memset(values, 0, sizeof(values));
+		memset(nulls, 0, sizeof(nulls));
 
 		values[0] = ObjectIdGetDatum(worker.subid);
 		if (OidIsValid(worker.relid))
diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c
index 21937ab2d3..f5cb766f66 100644
--- a/src/backend/replication/logical/origin.c
+++ b/src/backend/replication/logical/origin.c
@@ -524,7 +524,7 @@ ReplicationOriginShmemInit(void)
 	{
 		int			i;
 
-		MemSet(replication_states_ctl, 0, ReplicationOriginShmemSize());
+		memset(replication_states_ctl, 0, ReplicationOriginShmemSize());
 
 		replication_states_ctl->tranche_id = LWTRANCHE_REPLICATION_ORIGIN_STATE;
 
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index e5c2102bcd..7071d04aaa 100644
--- a/src/backend/replication/slot.c
+++ b/src/backend/replication/slot.c
@@ -147,7 +147,7 @@ ReplicationSlotsShmemInit(void)
 		int			i;
 
 		/* First time through, so initialize */
-		MemSet(ReplicationSlotCtl, 0, ReplicationSlotsShmemSize());
+		memset(ReplicationSlotCtl, 0, ReplicationSlotsShmemSize());
 
 		for (i = 0; i < max_replication_slots; i++)
 		{
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 9452932d59..3d37c1fe62 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1410,7 +1410,7 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
 		 * see details. Other users only get the pid value to know whether it
 		 * is a WAL receiver, but no details.
 		 */
-		MemSet(&nulls[1], true, sizeof(bool) * (tupdesc->natts - 1));
+		memset(&nulls[1], true, sizeof(bool) * (tupdesc->natts - 1));
 	}
 	else
 	{
diff --git a/src/backend/replication/walreceiverfuncs.c b/src/backend/replication/walreceiverfuncs.c
index 90798b9d53..3e4ac0788e 100644
--- a/src/backend/replication/walreceiverfuncs.c
+++ b/src/backend/replication/walreceiverfuncs.c
@@ -62,7 +62,7 @@ WalRcvShmemInit(void)
 	if (!found)
 	{
 		/* First time through, so initialize */
-		MemSet(WalRcv, 0, WalRcvShmemSize());
+		memset(WalRcv, 0, WalRcvShmemSize());
 		WalRcv->walRcvState = WALRCV_STOPPED;
 		ConditionVariableInit(&WalRcv->walRcvStoppedCV);
 		SpinLockInit(&WalRcv->mutex);
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index e42671722a..800a831c69 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -437,7 +437,7 @@ IdentifySystem(void)
 	}
 
 	dest = CreateDestReceiver(DestRemoteSimple);
-	MemSet(nulls, false, sizeof(nulls));
+	memset(nulls, false, sizeof(nulls));
 
 	/* need a tuple descriptor representing four columns */
 	tupdesc = CreateTemplateTupleDesc(4);
@@ -495,8 +495,8 @@ ReadReplicationSlot(ReadReplicationSlotCmd *cmd)
 	TupleDescInitBuiltinEntry(tupdesc, (AttrNumber) 3, "restart_tli",
 							  INT8OID, -1, 0);
 
-	MemSet(values, 0, READ_REPLICATION_SLOT_COLS * sizeof(Datum));
-	MemSet(nulls, true, READ_REPLICATION_SLOT_COLS * sizeof(bool));
+	memset(values, 0, READ_REPLICATION_SLOT_COLS * sizeof(Datum));
+	memset(nulls, true, READ_REPLICATION_SLOT_COLS * sizeof(bool));
 
 	LWLockAcquire(ReplicationSlotControlLock, LW_SHARED);
 	slot = SearchNamedReplicationSlot(cmd->slotname, false);
@@ -878,7 +878,7 @@ StartReplication(StartReplicationCmd *cmd)
 				 LSN_FORMAT_ARGS(sendTimeLineValidUpto));
 
 		dest = CreateDestReceiver(DestRemoteSimple);
-		MemSet(nulls, false, sizeof(nulls));
+		memset(nulls, false, sizeof(nulls));
 
 		/*
 		 * Need a tuple descriptor representing two columns. int8 may seem
@@ -1191,7 +1191,7 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
 			 LSN_FORMAT_ARGS(MyReplicationSlot->data.confirmed_flush));
 
 	dest = CreateDestReceiver(DestRemoteSimple);
-	MemSet(nulls, false, sizeof(nulls));
+	memset(nulls, false, sizeof(nulls));
 
 	/*----------
 	 * Need a tuple descriptor representing four columns:
@@ -3285,7 +3285,7 @@ WalSndShmemInit(void)
 	if (!found)
 	{
 		/* First time through, so initialize */
-		MemSet(WalSndCtl, 0, WalSndShmemSize());
+		memset(WalSndCtl, 0, WalSndShmemSize());
 
 		for (i = 0; i < NUM_SYNC_REP_WAIT_MODE; i++)
 			SHMQueueInit(&(WalSndCtl->SyncRepQueue[i]));
@@ -3550,7 +3550,7 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
 			 * can see details. Other users only get the pid value to know
 			 * it's a walsender, but no details.
 			 */
-			MemSet(&nulls[1], true, PG_STAT_GET_WAL_SENDERS_COLS - 1);
+			memset(&nulls[1], true, PG_STAT_GET_WAL_SENDERS_COLS - 1);
 		}
 		else
 		{
diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c
index 185bf5fbff..862aafeab7 100644
--- a/src/backend/rewrite/rewriteDefine.c
+++ b/src/backend/rewrite/rewriteDefine.c
@@ -81,7 +81,7 @@ InsertRule(const char *rulname,
 	/*
 	 * Set up *nulls and *values arrays
 	 */
-	MemSet(nulls, false, sizeof(nulls));
+	memset(nulls, false, sizeof(nulls));
 
 	namestrcpy(&rname, rulname);
 	values[Anum_pg_rewrite_rulename - 1] = NameGetDatum(&rname);
@@ -115,7 +115,7 @@ InsertRule(const char *rulname,
 		/*
 		 * When replacing, we don't need to replace every attribute
 		 */
-		MemSet(replaces, false, sizeof(replaces));
+		memset(replaces, false, sizeof(replaces));
 		replaces[Anum_pg_rewrite_ev_type - 1] = true;
 		replaces[Anum_pg_rewrite_is_instead - 1] = true;
 		replaces[Anum_pg_rewrite_ev_qual - 1] = true;
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index ae13011d27..eecf64aa98 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -981,7 +981,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
 	if (isExtend)
 	{
 		/* new buffers are zero-filled */
-		MemSet((char *) bufBlock, 0, BLCKSZ);
+		memset((char *) bufBlock, 0, BLCKSZ);
 		/* don't set checksum for all-zero page */
 		smgrextend(smgr, forkNum, blockNum, (char *) bufBlock, false);
 
@@ -999,7 +999,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
 		 * just wants us to allocate a buffer.
 		 */
 		if (mode == RBM_ZERO_AND_LOCK || mode == RBM_ZERO_AND_CLEANUP_LOCK)
-			MemSet((char *) bufBlock, 0, BLCKSZ);
+			memset((char *) bufBlock, 0, BLCKSZ);
 		else
 		{
 			instr_time	io_start,
@@ -1029,7 +1029,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
 							 errmsg("invalid page in block %u of relation %s; zeroing out page",
 									blockNum,
 									relpath(smgr->smgr_rnode, forkNum))));
-					MemSet((char *) bufBlock, 0, BLCKSZ);
+					memset((char *) bufBlock, 0, BLCKSZ);
 				}
 				else
 					ereport(ERROR,
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 24704b6a02..b13cbd18ae 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -891,7 +891,7 @@ InitFileAccess(void)
 				(errcode(ERRCODE_OUT_OF_MEMORY),
 				 errmsg("out of memory")));
 
-	MemSet((char *) &(VfdCache[0]), 0, sizeof(Vfd));
+	memset((char *) &(VfdCache[0]), 0, sizeof(Vfd));
 	VfdCache->fd = VFD_CLOSED;
 
 	SizeVfdCache = 1;
@@ -1439,7 +1439,7 @@ AllocateVfd(void)
 		 */
 		for (i = SizeVfdCache; i < newCacheSize; i++)
 		{
-			MemSet((char *) &(VfdCache[i]), 0, sizeof(Vfd));
+			memset((char *) &(VfdCache[i]), 0, sizeof(Vfd));
 			VfdCache[i].nextFree = i + 1;
 			VfdCache[i].fd = VFD_CLOSED;
 		}
diff --git a/src/backend/storage/ipc/pmsignal.c b/src/backend/storage/ipc/pmsignal.c
index 1c668d183c..b8d40ad5f7 100644
--- a/src/backend/storage/ipc/pmsignal.c
+++ b/src/backend/storage/ipc/pmsignal.c
@@ -141,7 +141,7 @@ PMSignalShmemInit(void)
 	if (!found)
 	{
 		/* initialize all flags to zeroes */
-		MemSet(unvolatize(PMSignalData *, PMSignalState), 0, PMSignalShmemSize());
+		memset(unvolatize(PMSignalData *, PMSignalState), 0, PMSignalShmemSize());
 		PMSignalState->num_child_flags = MaxLivePostmasterChildren();
 	}
 }
diff --git a/src/backend/storage/ipc/procsignal.c b/src/backend/storage/ipc/procsignal.c
index 21a9fc0fdd..ac5fcdc6ed 100644
--- a/src/backend/storage/ipc/procsignal.c
+++ b/src/backend/storage/ipc/procsignal.c
@@ -142,7 +142,7 @@ ProcSignalShmemInit(void)
 			ProcSignalSlot *slot = &ProcSignal->psh_slot[i];
 
 			slot->pss_pid = 0;
-			MemSet(slot->pss_signalFlags, 0, sizeof(slot->pss_signalFlags));
+			memset(slot->pss_signalFlags, 0, sizeof(slot->pss_signalFlags));
 			pg_atomic_init_u64(&slot->pss_barrierGeneration, PG_UINT64_MAX);
 			pg_atomic_init_u32(&slot->pss_barrierCheckMask, 0);
 			ConditionVariableInit(&slot->pss_barrierCV);
@@ -173,7 +173,7 @@ ProcSignalInit(int pss_idx)
 			 MyProcPid, pss_idx);
 
 	/* Clear out any leftover signal reasons */
-	MemSet(slot->pss_signalFlags, 0, NUM_PROCSIGNALS * sizeof(sig_atomic_t));
+	memset(slot->pss_signalFlags, 0, NUM_PROCSIGNALS * sizeof(sig_atomic_t));
 
 	/*
 	 * Initialize barrier state. Since we're a brand-new process, there
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c
index d204482a61..bf5016bbbf 100644
--- a/src/backend/storage/large_object/inv_api.c
+++ b/src/backend/storage/large_object/inv_api.c
@@ -546,7 +546,7 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
 		{
 			n = pageoff - obj_desc->offset;
 			n = (n <= (nbytes - nread)) ? n : (nbytes - nread);
-			MemSet(buf + nread, 0, n);
+			memset(buf + nread, 0, n);
 			nread += n;
 			obj_desc->offset += n;
 		}
@@ -689,7 +689,7 @@ inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes)
 			 */
 			off = (int) (obj_desc->offset % LOBLKSIZE);
 			if (off > len)
-				MemSet(workb + len, 0, off - len);
+				memset(workb + len, 0, off - len);
 
 			/*
 			 * Insert appropriate portion of new data
@@ -734,7 +734,7 @@ inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes)
 			 */
 			off = (int) (obj_desc->offset % LOBLKSIZE);
 			if (off > 0)
-				MemSet(workb, 0, off);
+				memset(workb, 0, off);
 
 			/*
 			 * Insert appropriate portion of new data
@@ -874,7 +874,7 @@ inv_truncate(LargeObjectDesc *obj_desc, int64 len)
 		 */
 		off = len % LOBLKSIZE;
 		if (off > pagelen)
-			MemSet(workb + pagelen, 0, off - pagelen);
+			memset(workb + pagelen, 0, off - pagelen);
 
 		/* compute length of new page */
 		SET_VARSIZE(&workbuf.hdr, off + VARHDRSZ);
@@ -913,7 +913,7 @@ inv_truncate(LargeObjectDesc *obj_desc, int64 len)
 		 */
 		off = len % LOBLKSIZE;
 		if (off > 0)
-			MemSet(workb, 0, off);
+			memset(workb, 0, off);
 
 		/* compute length of new page */
 		SET_VARSIZE(&workbuf.hdr, off + VARHDRSZ);
diff --git a/src/backend/storage/lmgr/deadlock.c b/src/backend/storage/lmgr/deadlock.c
index cd9c0418ec..6c6c1eb167 100644
--- a/src/backend/storage/lmgr/deadlock.c
+++ b/src/backend/storage/lmgr/deadlock.c
@@ -918,8 +918,8 @@ TopoSort(LOCK *lock,
 	 * present.  If so, the constraint is relevant to this wait queue; if not,
 	 * it isn't.
 	 */
-	MemSet(beforeConstraints, 0, queue_size * sizeof(int));
-	MemSet(afterConstraints, 0, queue_size * sizeof(int));
+	memset(beforeConstraints, 0, queue_size * sizeof(int));
+	memset(afterConstraints, 0, queue_size * sizeof(int));
 	for (i = 0; i < nConstraints; i++)
 	{
 		/*
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c
index 5f5803f681..ec2ea6c42e 100644
--- a/src/backend/storage/lmgr/lock.c
+++ b/src/backend/storage/lmgr/lock.c
@@ -603,7 +603,7 @@ LockHeldByMe(const LOCKTAG *locktag, LOCKMODE lockmode)
 	/*
 	 * See if there is a LOCALLOCK entry for this lock and lockmode
 	 */
-	MemSet(&localtag, 0, sizeof(localtag)); /* must clear padding */
+	memset(&localtag, 0, sizeof(localtag)); /* must clear padding */
 	localtag.lock = *locktag;
 	localtag.mode = lockmode;
 
@@ -658,7 +658,7 @@ LockHasWaiters(const LOCKTAG *locktag, LOCKMODE lockmode, bool sessionLock)
 	/*
 	 * Find the LOCALLOCK entry for this lock and lockmode
 	 */
-	MemSet(&localtag, 0, sizeof(localtag)); /* must clear padding */
+	memset(&localtag, 0, sizeof(localtag)); /* must clear padding */
 	localtag.lock = *locktag;
 	localtag.mode = lockmode;
 
@@ -820,7 +820,7 @@ LockAcquireExtended(const LOCKTAG *locktag,
 	/*
 	 * Find or create a LOCALLOCK entry for this lock and lockmode
 	 */
-	MemSet(&localtag, 0, sizeof(localtag)); /* must clear padding */
+	memset(&localtag, 0, sizeof(localtag)); /* must clear padding */
 	localtag.lock = *locktag;
 	localtag.mode = lockmode;
 
@@ -1198,8 +1198,8 @@ SetupLockInTable(LockMethod lockMethodTable, PGPROC *proc,
 		ProcQueueInit(&(lock->waitProcs));
 		lock->nRequested = 0;
 		lock->nGranted = 0;
-		MemSet(lock->requested, 0, sizeof(int) * MAX_LOCKMODES);
-		MemSet(lock->granted, 0, sizeof(int) * MAX_LOCKMODES);
+		memset(lock->requested, 0, sizeof(int) * MAX_LOCKMODES);
+		memset(lock->granted, 0, sizeof(int) * MAX_LOCKMODES);
 		LOCK_PRINT("LockAcquire: new", lock, lockmode);
 	}
 	else
@@ -1999,7 +1999,7 @@ LockRelease(const LOCKTAG *locktag, LOCKMODE lockmode, bool sessionLock)
 	/*
 	 * Find the LOCALLOCK entry for this lock and lockmode
 	 */
-	MemSet(&localtag, 0, sizeof(localtag)); /* must clear padding */
+	memset(&localtag, 0, sizeof(localtag)); /* must clear padding */
 	localtag.lock = *locktag;
 	localtag.mode = lockmode;
 
@@ -4271,8 +4271,8 @@ lock_twophase_recover(TransactionId xid, uint16 info,
 		ProcQueueInit(&(lock->waitProcs));
 		lock->nRequested = 0;
 		lock->nGranted = 0;
-		MemSet(lock->requested, 0, sizeof(int) * MAX_LOCKMODES);
-		MemSet(lock->granted, 0, sizeof(int) * MAX_LOCKMODES);
+		memset(lock->requested, 0, sizeof(int) * MAX_LOCKMODES);
+		memset(lock->granted, 0, sizeof(int) * MAX_LOCKMODES);
 		LOCK_PRINT("lock_twophase_recover: new", lock, lockmode);
 	}
 	else
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c
index 8aef909037..c09b127cf6 100644
--- a/src/backend/storage/lmgr/lwlock.c
+++ b/src/backend/storage/lmgr/lwlock.c
@@ -397,7 +397,7 @@ get_lwlock_stats_entry(LWLock *lock)
 		return &lwlock_stats_dummy;
 
 	/* Fetch or create the entry. */
-	MemSet(&key, 0, sizeof(key));
+	memset(&key, 0, sizeof(key));
 	key.tranche = lock->tranche;
 	key.instance = lock;
 	lwstats = hash_search(lwlock_stats_htab, &key, HASH_ENTER, &found);
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index 37aaab1338..e732d61220 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -192,7 +192,7 @@ InitProcGlobal(void)
 	 * between groups.
 	 */
 	procs = (PGPROC *) ShmemAlloc(TotalProcs * sizeof(PGPROC));
-	MemSet(procs, 0, TotalProcs * sizeof(PGPROC));
+	memset(procs, 0, TotalProcs * sizeof(PGPROC));
 	ProcGlobal->allProcs = procs;
 	/* XXX allProcCount isn't really all of them; it excludes prepared xacts */
 	ProcGlobal->allProcCount = MaxBackends + NUM_AUXILIARY_PROCS;
@@ -206,11 +206,11 @@ InitProcGlobal(void)
 	 */
 	ProcGlobal->xids =
 		(TransactionId *) ShmemAlloc(TotalProcs * sizeof(*ProcGlobal->xids));
-	MemSet(ProcGlobal->xids, 0, TotalProcs * sizeof(*ProcGlobal->xids));
+	memset(ProcGlobal->xids, 0, TotalProcs * sizeof(*ProcGlobal->xids));
 	ProcGlobal->subxidStates = (XidCacheStatus *) ShmemAlloc(TotalProcs * sizeof(*ProcGlobal->subxidStates));
-	MemSet(ProcGlobal->subxidStates, 0, TotalProcs * sizeof(*ProcGlobal->subxidStates));
+	memset(ProcGlobal->subxidStates, 0, TotalProcs * sizeof(*ProcGlobal->subxidStates));
 	ProcGlobal->statusFlags = (uint8 *) ShmemAlloc(TotalProcs * sizeof(*ProcGlobal->statusFlags));
-	MemSet(ProcGlobal->statusFlags, 0, TotalProcs * sizeof(*ProcGlobal->statusFlags));
+	memset(ProcGlobal->statusFlags, 0, TotalProcs * sizeof(*ProcGlobal->statusFlags));
 
 	for (i = 0; i < TotalProcs; i++)
 	{
diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c
index a3d367db51..b75cb7e943 100644
--- a/src/backend/storage/page/bufpage.c
+++ b/src/backend/storage/page/bufpage.c
@@ -49,14 +49,14 @@ PageInit(Page page, Size pageSize, Size specialSize)
 	Assert(pageSize > specialSize + SizeOfPageHeaderData);
 
 	/* Make sure all fields of page are zero, as well as unused space */
-	MemSet(p, 0, pageSize);
+	memset(p, 0, pageSize);
 
 	p->pd_flags = 0;
 	p->pd_lower = SizeOfPageHeaderData;
 	p->pd_upper = pageSize - specialSize;
 	p->pd_special = pageSize - specialSize;
 	PageSetPageSizeAndVersion(page, pageSize, PG_PAGE_LAYOUT_VERSION);
-	/* p->pd_prune_xid = InvalidTransactionId;		done by above MemSet */
+	/* p->pd_prune_xid = InvalidTransactionId;		done by above memset */
 }
 
 
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index 43edaf5d87..4aae2decbb 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -684,7 +684,7 @@ mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
 		 * update a block that was later truncated away.
 		 */
 		if (zero_damaged_pages || InRecovery)
-			MemSet(buffer, 0, BLCKSZ);
+			memset(buffer, 0, BLCKSZ);
 		else
 			ereport(ERROR,
 					(errcode(ERRCODE_DATA_CORRUPTED),
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c
index d429aa4663..c6ec536463 100644
--- a/src/backend/tcop/fastpath.c
+++ b/src/backend/tcop/fastpath.c
@@ -131,7 +131,7 @@ fetch_fp_info(Oid func_id, struct fp_info *fip)
 	 * time.  [No longer really an issue since we don't save the struct
 	 * fp_info across transactions anymore, but keep it anyway.]
 	 */
-	MemSet(fip, 0, sizeof(struct fp_info));
+	memset(fip, 0, sizeof(struct fp_info));
 	fip->funcid = InvalidOid;
 
 	func_htp = SearchSysCache1(PROCOID, ObjectIdGetDatum(func_id));
diff --git a/src/backend/utils/activity/backend_progress.c b/src/backend/utils/activity/backend_progress.c
index f29199725b..d12402a050 100644
--- a/src/backend/utils/activity/backend_progress.c
+++ b/src/backend/utils/activity/backend_progress.c
@@ -33,7 +33,7 @@ pgstat_progress_start_command(ProgressCommandType cmdtype, Oid relid)
 	PGSTAT_BEGIN_WRITE_ACTIVITY(beentry);
 	beentry->st_progress_command = cmdtype;
 	beentry->st_progress_command_target = relid;
-	MemSet(&beentry->st_progress_param, 0, sizeof(beentry->st_progress_param));
+	memset(&beentry->st_progress_param, 0, sizeof(beentry->st_progress_param));
 	PGSTAT_END_WRITE_ACTIVITY(beentry);
 }
 
diff --git a/src/backend/utils/activity/backend_status.c b/src/backend/utils/activity/backend_status.c
index c7ed1e6d7a..96f0a815c1 100644
--- a/src/backend/utils/activity/backend_status.c
+++ b/src/backend/utils/activity/backend_status.c
@@ -131,7 +131,7 @@ CreateSharedBackendStatus(void)
 		/*
 		 * We're the first - initialize.
 		 */
-		MemSet(BackendStatusArray, 0, size);
+		memset(BackendStatusArray, 0, size);
 	}
 
 	/* Create or attach to the shared appname buffer */
@@ -141,7 +141,7 @@ CreateSharedBackendStatus(void)
 
 	if (!found)
 	{
-		MemSet(BackendAppnameBuffer, 0, size);
+		memset(BackendAppnameBuffer, 0, size);
 
 		/* Initialize st_appname pointers. */
 		buffer = BackendAppnameBuffer;
@@ -159,7 +159,7 @@ CreateSharedBackendStatus(void)
 
 	if (!found)
 	{
-		MemSet(BackendClientHostnameBuffer, 0, size);
+		memset(BackendClientHostnameBuffer, 0, size);
 
 		/* Initialize st_clienthostname pointers. */
 		buffer = BackendClientHostnameBuffer;
@@ -180,7 +180,7 @@ CreateSharedBackendStatus(void)
 
 	if (!found)
 	{
-		MemSet(BackendActivityBuffer, 0, BackendActivityBufferSize);
+		memset(BackendActivityBuffer, 0, BackendActivityBufferSize);
 
 		/* Initialize st_activity pointers. */
 		buffer = BackendActivityBuffer;
@@ -201,7 +201,7 @@ CreateSharedBackendStatus(void)
 	{
 		PgBackendSSLStatus *ptr;
 
-		MemSet(BackendSslStatusBuffer, 0, size);
+		memset(BackendSslStatusBuffer, 0, size);
 
 		/* Initialize st_sslstatus pointers. */
 		ptr = BackendSslStatusBuffer;
@@ -223,7 +223,7 @@ CreateSharedBackendStatus(void)
 	{
 		PgBackendGSSStatus *ptr;
 
-		MemSet(BackendGssStatusBuffer, 0, size);
+		memset(BackendGssStatusBuffer, 0, size);
 
 		/* Initialize st_gssstatus pointers. */
 		ptr = BackendGssStatusBuffer;
@@ -355,7 +355,7 @@ pgstat_bestart(void)
 		memcpy(&lbeentry.st_clientaddr, &MyProcPort->raddr,
 			   sizeof(lbeentry.st_clientaddr));
 	else
-		MemSet(&lbeentry.st_clientaddr, 0, sizeof(lbeentry.st_clientaddr));
+		memset(&lbeentry.st_clientaddr, 0, sizeof(lbeentry.st_clientaddr));
 
 #ifdef USE_SSL
 	if (MyProcPort && MyProcPort->ssl_in_use)
diff --git a/src/backend/utils/activity/pgstat_bgwriter.c b/src/backend/utils/activity/pgstat_bgwriter.c
index fbb1edc527..ced6e10a2a 100644
--- a/src/backend/utils/activity/pgstat_bgwriter.c
+++ b/src/backend/utils/activity/pgstat_bgwriter.c
@@ -55,7 +55,7 @@ pgstat_report_bgwriter(void)
 	/*
 	 * Clear out the statistics buffer, so it can be re-used.
 	 */
-	MemSet(&PendingBgWriterStats, 0, sizeof(PendingBgWriterStats));
+	memset(&PendingBgWriterStats, 0, sizeof(PendingBgWriterStats));
 }
 
 /*
diff --git a/src/backend/utils/activity/pgstat_checkpointer.c b/src/backend/utils/activity/pgstat_checkpointer.c
index af8d513e7b..ba64aec5c5 100644
--- a/src/backend/utils/activity/pgstat_checkpointer.c
+++ b/src/backend/utils/activity/pgstat_checkpointer.c
@@ -61,7 +61,7 @@ pgstat_report_checkpointer(void)
 	/*
 	 * Clear out the statistics buffer, so it can be re-used.
 	 */
-	MemSet(&PendingCheckpointerStats, 0, sizeof(PendingCheckpointerStats));
+	memset(&PendingCheckpointerStats, 0, sizeof(PendingCheckpointerStats));
 }
 
 /*
diff --git a/src/backend/utils/activity/pgstat_slru.c b/src/backend/utils/activity/pgstat_slru.c
index d0b85b62a5..0c1eb70251 100644
--- a/src/backend/utils/activity/pgstat_slru.c
+++ b/src/backend/utils/activity/pgstat_slru.c
@@ -185,7 +185,7 @@ pgstat_slru_flush(bool nowait)
 	}
 
 	/* done, clear the pending entry */
-	MemSet(pending_SLRUStats, 0, sizeof(pending_SLRUStats));
+	memset(pending_SLRUStats, 0, sizeof(pending_SLRUStats));
 
 	LWLockRelease(&stats_shmem->lock);
 
diff --git a/src/backend/utils/activity/pgstat_wal.c b/src/backend/utils/activity/pgstat_wal.c
index 5a878bd115..d6f9866ba7 100644
--- a/src/backend/utils/activity/pgstat_wal.c
+++ b/src/backend/utils/activity/pgstat_wal.c
@@ -117,7 +117,7 @@ pgstat_flush_wal(bool nowait)
 	/*
 	 * Clear out the statistics buffer, so it can be re-used.
 	 */
-	MemSet(&PendingWalStats, 0, sizeof(PendingWalStats));
+	memset(&PendingWalStats, 0, sizeof(PendingWalStats));
 
 	return false;
 }
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c
index 772c04155c..2ee786dc6b 100644
--- a/src/backend/utils/adt/acl.c
+++ b/src/backend/utils/adt/acl.c
@@ -1819,7 +1819,7 @@ aclexplode(PG_FUNCTION_ARGS)
 			values[2] = CStringGetTextDatum(convert_aclright_to_string(priv_bit));
 			values[3] = BoolGetDatum((ACLITEM_GET_GOPTIONS(*aidata) & priv_bit) != 0);
 
-			MemSet(nulls, 0, sizeof(nulls));
+			memset(nulls, 0, sizeof(nulls));
 
 			tuple = heap_form_tuple(funcctx->tuple_desc, values, nulls);
 			result = HeapTupleGetDatum(tuple);
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index 2570e5e630..14b7532b67 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -746,7 +746,7 @@ ReadArrayStr(char *arrayStr,
 				prod[MAXDIM];
 
 	mda_get_prod(ndim, dim, prod);
-	MemSet(indx, 0, sizeof(indx));
+	memset(indx, 0, sizeof(indx));
 
 	/* Initialize is-null markers to true */
 	memset(nulls, true, nitems * sizeof(bool));
@@ -2460,7 +2460,7 @@ array_set_element(Datum arraydatum,
 		bits8	   *newnullbitmap = ARR_NULLBITMAP(newarray);
 
 		/* Zero the bitmap to take care of marking inserted positions null */
-		MemSet(newnullbitmap, 0, (newnitems + 7) / 8);
+		memset(newnullbitmap, 0, (newnitems + 7) / 8);
 		/* Fix the inserted value */
 		if (addedafter)
 			array_set_isnull(newnullbitmap, newnitems - 1, isNull);
@@ -3077,7 +3077,7 @@ array_set_slice(Datum arraydatum,
 			bits8	   *oldnullbitmap = ARR_NULLBITMAP(array);
 
 			/* Zero the bitmap to handle marking inserted positions null */
-			MemSet(newnullbitmap, 0, (nitems + 7) / 8);
+			memset(newnullbitmap, 0, (nitems + 7) / 8);
 			array_bitmap_copy(newnullbitmap, addedbefore,
 							  oldnullbitmap, 0,
 							  itemsbefore);
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 4c12c4d663..99ef3df049 100644
--- a/src/backend/utils/adt/datetime.c
+++ b/src/backend/utils/adt/datetime.c
@@ -5011,7 +5011,7 @@ pg_timezone_abbrevs(PG_FUNCTION_ARGS)
 			break;
 	}
 
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(nulls, 0, sizeof(nulls));
 
 	/*
 	 * Convert name to text, using upcasing conversion that is the inverse of
@@ -5024,7 +5024,7 @@ pg_timezone_abbrevs(PG_FUNCTION_ARGS)
 	values[0] = CStringGetTextDatum(buffer);
 
 	/* Convert offset (in seconds) to an interval; can't overflow */
-	MemSet(&itm_in, 0, sizeof(struct pg_itm_in));
+	memset(&itm_in, 0, sizeof(struct pg_itm_in));
 	itm_in.tm_usec = (int64) gmtoffset * USECS_PER_SEC;
 	resInterval = (Interval *) palloc(sizeof(Interval));
 	(void) itmin2interval(&itm_in, resInterval);
@@ -5088,13 +5088,13 @@ pg_timezone_names(PG_FUNCTION_ARGS)
 		if (tzn && strlen(tzn) > 31)
 			continue;
 
-		MemSet(nulls, 0, sizeof(nulls));
+		memset(nulls, 0, sizeof(nulls));
 
 		values[0] = CStringGetTextDatum(pg_get_timezone_name(tz));
 		values[1] = CStringGetTextDatum(tzn ? tzn : "");
 
 		/* Convert tzoff to an interval; can't overflow */
-		MemSet(&itm_in, 0, sizeof(struct pg_itm_in));
+		memset(&itm_in, 0, sizeof(struct pg_itm_in));
 		itm_in.tm_usec = (int64) -tzoff * USECS_PER_SEC;
 		resInterval = (Interval *) palloc(sizeof(Interval));
 		(void) itmin2interval(&itm_in, resInterval);
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index e909c1a200..31105b9519 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -5626,7 +5626,7 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout,
 	const char *pattern;
 	int			pattern_len;
 
-	MemSet(Np, 0, sizeof(NUMProc));
+	memset(Np, 0, sizeof(NUMProc));
 
 	Np->Num = Num;
 	Np->is_to_char = is_to_char;
diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
index d427bdfbe0..52ff421e36 100644
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -3190,7 +3190,7 @@ allocate_record_info(MemoryContext mcxt, int ncolumns)
 	data->record_type = InvalidOid;
 	data->record_typmod = 0;
 	data->ncolumns = ncolumns;
-	MemSet(data->columns, 0, sizeof(ColumnIOData) * ncolumns);
+	memset(data->columns, 0, sizeof(ColumnIOData) * ncolumns);
 
 	return data;
 }
@@ -3254,7 +3254,7 @@ populate_record(TupleDesc tupdesc,
 	if (record->record_type != tupdesc->tdtypeid ||
 		record->record_typmod != tupdesc->tdtypmod)
 	{
-		MemSet(record, 0, offsetof(RecordIOData, columns) +
+		memset(record, 0, offsetof(RecordIOData, columns) +
 			   ncolumns * sizeof(ColumnIOData));
 		record->record_type = tupdesc->tdtypeid;
 		record->record_typmod = tupdesc->tdtypmod;
diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lockfuncs.c
index 023a004ac8..6c5f9ebaee 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -230,8 +230,8 @@ pg_lock_status(PG_FUNCTION_ARGS)
 		/*
 		 * Form tuple with appropriate data.
 		 */
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, false, sizeof(nulls));
+		memset(values, 0, sizeof(values));
+		memset(nulls, false, sizeof(nulls));
 
 		if (instance->locktag.locktag_type <= LOCKTAG_LAST_TYPE)
 			locktypename = LockTagTypeNames[instance->locktag.locktag_type];
@@ -369,8 +369,8 @@ pg_lock_status(PG_FUNCTION_ARGS)
 		/*
 		 * Form tuple with appropriate data.
 		 */
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, false, sizeof(nulls));
+		memset(values, 0, sizeof(values));
+		memset(nulls, false, sizeof(nulls));
 
 		/* lock type */
 		lockType = GET_PREDICATELOCKTARGETTAG_TYPE(*predTag);
diff --git a/src/backend/utils/adt/partitionfuncs.c b/src/backend/utils/adt/partitionfuncs.c
index 0243bc061f..468bd7b34f 100644
--- a/src/backend/utils/adt/partitionfuncs.c
+++ b/src/backend/utils/adt/partitionfuncs.c
@@ -126,8 +126,8 @@ pg_partition_tree(PG_FUNCTION_ARGS)
 		/*
 		 * Form tuple with appropriate data.
 		 */
-		MemSet(nulls, 0, sizeof(nulls));
-		MemSet(values, 0, sizeof(values));
+		memset(nulls, 0, sizeof(nulls));
+		memset(values, 0, sizeof(values));
 
 		/* relid */
 		values[0] = ObjectIdGetDatum(relid);
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
index 893690dad5..94db404d02 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -492,8 +492,8 @@ pg_stat_get_progress_info(PG_FUNCTION_ARGS)
 		bool		nulls[PG_STAT_GET_PROGRESS_COLS];
 		int			i;
 
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, 0, sizeof(nulls));
+		memset(values, 0, sizeof(values));
+		memset(nulls, 0, sizeof(nulls));
 
 		local_beentry = pgstat_fetch_stat_local_beentry(curr_backend);
 
@@ -559,8 +559,8 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
 		const char *wait_event_type = NULL;
 		const char *wait_event = NULL;
 
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, 0, sizeof(nulls));
+		memset(values, 0, sizeof(values));
+		memset(nulls, 0, sizeof(nulls));
 
 		/* Get the next one in the list */
 		local_beentry = pgstat_fetch_stat_local_beentry(curr_backend);
@@ -1753,8 +1753,8 @@ pg_stat_get_wal(PG_FUNCTION_ARGS)
 	PgStat_WalStats *wal_stats;
 
 	/* Initialise values and NULL flags arrays */
-	MemSet(values, 0, sizeof(values));
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(values, 0, sizeof(values));
+	memset(nulls, 0, sizeof(nulls));
 
 	/* Initialise attributes information in the tuple descriptor */
 	tupdesc = CreateTemplateTupleDesc(PG_STAT_GET_WAL_COLS);
@@ -1837,8 +1837,8 @@ pg_stat_get_slru(PG_FUNCTION_ARGS)
 			break;
 
 		stat = stats[i];
-		MemSet(values, 0, sizeof(values));
-		MemSet(nulls, 0, sizeof(nulls));
+		memset(values, 0, sizeof(values));
+		memset(nulls, 0, sizeof(nulls));
 
 		values[0] = PointerGetDatum(cstring_to_text(name));
 		values[1] = Int64GetDatum(stat.blocks_zeroed);
@@ -2206,8 +2206,8 @@ pg_stat_get_archiver(PG_FUNCTION_ARGS)
 	PgStat_ArchiverStats *archiver_stats;
 
 	/* Initialise values and NULL flags arrays */
-	MemSet(values, 0, sizeof(values));
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(values, 0, sizeof(values));
+	memset(nulls, 0, sizeof(nulls));
 
 	/* Initialise attributes information in the tuple descriptor */
 	tupdesc = CreateTemplateTupleDesc(7);
@@ -2280,8 +2280,8 @@ pg_stat_get_replication_slot(PG_FUNCTION_ARGS)
 	PgStat_StatReplSlotEntry allzero;
 
 	/* Initialise values and NULL flags arrays */
-	MemSet(values, 0, sizeof(values));
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(values, 0, sizeof(values));
+	memset(nulls, 0, sizeof(nulls));
 
 	/* Initialise attributes information in the tuple descriptor */
 	tupdesc = CreateTemplateTupleDesc(PG_STAT_GET_REPLICATION_SLOT_COLS);
@@ -2369,8 +2369,8 @@ pg_stat_get_subscription_stats(PG_FUNCTION_ARGS)
 	BlessTupleDesc(tupdesc);
 
 	/* Initialise values and NULL flags arrays */
-	MemSet(values, 0, sizeof(values));
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(values, 0, sizeof(values));
+	memset(nulls, 0, sizeof(nulls));
 
 	if (!subentry)
 	{
diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c
index db843a0fbf..7c9eefc741 100644
--- a/src/backend/utils/adt/rowtypes.c
+++ b/src/backend/utils/adt/rowtypes.c
@@ -132,7 +132,7 @@ record_in(PG_FUNCTION_ARGS)
 	if (my_extra->record_type != tupType ||
 		my_extra->record_typmod != tupTypmod)
 	{
-		MemSet(my_extra, 0,
+		memset(my_extra, 0,
 			   offsetof(RecordIOData, columns) +
 			   ncolumns * sizeof(ColumnIOData));
 		my_extra->record_type = tupType;
@@ -349,7 +349,7 @@ record_out(PG_FUNCTION_ARGS)
 	if (my_extra->record_type != tupType ||
 		my_extra->record_typmod != tupTypmod)
 	{
-		MemSet(my_extra, 0,
+		memset(my_extra, 0,
 			   offsetof(RecordIOData, columns) +
 			   ncolumns * sizeof(ColumnIOData));
 		my_extra->record_type = tupType;
@@ -505,7 +505,7 @@ record_recv(PG_FUNCTION_ARGS)
 	if (my_extra->record_type != tupType ||
 		my_extra->record_typmod != tupTypmod)
 	{
-		MemSet(my_extra, 0,
+		memset(my_extra, 0,
 			   offsetof(RecordIOData, columns) +
 			   ncolumns * sizeof(ColumnIOData));
 		my_extra->record_type = tupType;
@@ -716,7 +716,7 @@ record_send(PG_FUNCTION_ARGS)
 	if (my_extra->record_type != tupType ||
 		my_extra->record_typmod != tupTypmod)
 	{
-		MemSet(my_extra, 0,
+		memset(my_extra, 0,
 			   offsetof(RecordIOData, columns) +
 			   ncolumns * sizeof(ColumnIOData));
 		my_extra->record_type = tupType;
@@ -876,7 +876,7 @@ record_cmp(FunctionCallInfo fcinfo)
 		my_extra->record2_type != tupType2 ||
 		my_extra->record2_typmod != tupTypmod2)
 	{
-		MemSet(my_extra->columns, 0, ncols * sizeof(ColumnCompareData));
+		memset(my_extra->columns, 0, ncols * sizeof(ColumnCompareData));
 		my_extra->record1_type = tupType1;
 		my_extra->record1_typmod = tupTypmod1;
 		my_extra->record2_type = tupType2;
@@ -1120,7 +1120,7 @@ record_eq(PG_FUNCTION_ARGS)
 		my_extra->record2_type != tupType2 ||
 		my_extra->record2_typmod != tupTypmod2)
 	{
-		MemSet(my_extra->columns, 0, ncols * sizeof(ColumnCompareData));
+		memset(my_extra->columns, 0, ncols * sizeof(ColumnCompareData));
 		my_extra->record1_type = tupType1;
 		my_extra->record1_typmod = tupTypmod1;
 		my_extra->record2_type = tupType2;
@@ -1382,7 +1382,7 @@ record_image_cmp(FunctionCallInfo fcinfo)
 		my_extra->record2_type != tupType2 ||
 		my_extra->record2_typmod != tupTypmod2)
 	{
-		MemSet(my_extra->columns, 0, ncols * sizeof(ColumnCompareData));
+		memset(my_extra->columns, 0, ncols * sizeof(ColumnCompareData));
 		my_extra->record1_type = tupType1;
 		my_extra->record1_typmod = tupTypmod1;
 		my_extra->record2_type = tupType2;
@@ -1628,7 +1628,7 @@ record_image_eq(PG_FUNCTION_ARGS)
 		my_extra->record2_type != tupType2 ||
 		my_extra->record2_typmod != tupTypmod2)
 	{
-		MemSet(my_extra->columns, 0, ncols * sizeof(ColumnCompareData));
+		memset(my_extra->columns, 0, ncols * sizeof(ColumnCompareData));
 		my_extra->record1_type = tupType1;
 		my_extra->record1_typmod = tupTypmod1;
 		my_extra->record2_type = tupType2;
@@ -1822,7 +1822,7 @@ hash_record(PG_FUNCTION_ARGS)
 	if (my_extra->record1_type != tupType ||
 		my_extra->record1_typmod != tupTypmod)
 	{
-		MemSet(my_extra->columns, 0, ncolumns * sizeof(ColumnCompareData));
+		memset(my_extra->columns, 0, ncolumns * sizeof(ColumnCompareData));
 		my_extra->record1_type = tupType;
 		my_extra->record1_typmod = tupTypmod;
 	}
@@ -1943,7 +1943,7 @@ hash_record_extended(PG_FUNCTION_ARGS)
 	if (my_extra->record1_type != tupType ||
 		my_extra->record1_typmod != tupTypmod)
 	{
-		MemSet(my_extra->columns, 0, ncolumns * sizeof(ColumnCompareData));
+		memset(my_extra->columns, 0, ncolumns * sizeof(ColumnCompareData));
 		my_extra->record1_type = tupType;
 		my_extra->record1_typmod = tupTypmod;
 	}
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index fa1f589fad..243feb2340 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -4992,7 +4992,7 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid,
 	RelOptInfo *onerel;
 
 	/* Make sure we don't return dangling pointers in vardata */
-	MemSet(vardata, 0, sizeof(VariableStatData));
+	memset(vardata, 0, sizeof(VariableStatData));
 
 	/* Save the exposed type of the expression */
 	vardata->vartype = exprType(node);
@@ -6797,7 +6797,7 @@ btcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
 	/*
 	 * Now do generic index cost estimation.
 	 */
-	MemSet(&costs, 0, sizeof(costs));
+	memset(&costs, 0, sizeof(costs));
 	costs.numIndexTuples = numIndexTuples;
 
 	genericcostestimate(root, path, loop_count, &costs);
@@ -6842,7 +6842,7 @@ btcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
 	 * ordering, but don't negate it entirely.  Before 8.0 we divided the
 	 * correlation by the number of columns, but that seems too strong.)
 	 */
-	MemSet(&vardata, 0, sizeof(vardata));
+	memset(&vardata, 0, sizeof(vardata));
 
 	if (index->indexkeys[0] != 0)
 	{
@@ -6949,7 +6949,7 @@ hashcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
 {
 	GenericCosts costs;
 
-	MemSet(&costs, 0, sizeof(costs));
+	memset(&costs, 0, sizeof(costs));
 
 	genericcostestimate(root, path, loop_count, &costs);
 
@@ -6995,7 +6995,7 @@ gistcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
 	GenericCosts costs;
 	Cost		descentCost;
 
-	MemSet(&costs, 0, sizeof(costs));
+	memset(&costs, 0, sizeof(costs));
 
 	genericcostestimate(root, path, loop_count, &costs);
 
@@ -7052,7 +7052,7 @@ spgcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
 	GenericCosts costs;
 	Cost		descentCost;
 
-	MemSet(&costs, 0, sizeof(costs));
+	memset(&costs, 0, sizeof(costs));
 
 	genericcostestimate(root, path, loop_count, &costs);
 
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index f70f829d83..0821a4e639 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -5800,7 +5800,7 @@ generate_series_timestamp(PG_FUNCTION_ARGS)
 		fctx->step = *step;
 
 		/* Determine sign of the interval */
-		MemSet(&interval_zero, 0, sizeof(Interval));
+		memset(&interval_zero, 0, sizeof(Interval));
 		fctx->step_sign = interval_cmp_internal(&fctx->step, &interval_zero);
 
 		if (fctx->step_sign == 0)
@@ -5880,7 +5880,7 @@ generate_series_timestamptz(PG_FUNCTION_ARGS)
 		fctx->step = *step;
 
 		/* Determine sign of the interval */
-		MemSet(&interval_zero, 0, sizeof(Interval));
+		memset(&interval_zero, 0, sizeof(Interval));
 		fctx->step_sign = interval_cmp_internal(&fctx->step, &interval_zero);
 
 		if (fctx->step_sign == 0)
diff --git a/src/backend/utils/adt/tsgistidx.c b/src/backend/utils/adt/tsgistidx.c
index b8fd96dd7b..9b73030fa8 100644
--- a/src/backend/utils/adt/tsgistidx.c
+++ b/src/backend/utils/adt/tsgistidx.c
@@ -141,7 +141,7 @@ makesign(BITVECP sign, SignTSVector *a, int siglen)
 				len = ARRNELEM(a);
 	int32	   *ptr = GETARR(a);
 
-	MemSet((void *) sign, 0, siglen);
+	memset((void *) sign, 0, siglen);
 	for (k = 0; k < len; k++)
 		HASH(sign, ptr[k], siglen);
 }
@@ -753,7 +753,7 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
 			if (ISALLTRUE(datum_l) || cache[j].allistrue)
 			{
 				if (!ISALLTRUE(datum_l))
-					MemSet((void *) GETSIGN(datum_l), 0xff, siglen);
+					memset((void *) GETSIGN(datum_l), 0xff, siglen);
 			}
 			else
 			{
@@ -769,7 +769,7 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
 			if (ISALLTRUE(datum_r) || cache[j].allistrue)
 			{
 				if (!ISALLTRUE(datum_r))
-					MemSet((void *) GETSIGN(datum_r), 0xff, siglen);
+					memset((void *) GETSIGN(datum_r), 0xff, siglen);
 			}
 			else
 			{
diff --git a/src/backend/utils/adt/tsrank.c b/src/backend/utils/adt/tsrank.c
index 3858fc5928..da8a777fad 100644
--- a/src/backend/utils/adt/tsrank.c
+++ b/src/backend/utils/adt/tsrank.c
@@ -883,7 +883,7 @@ calc_rank_cd(const float4 *arrdata, TSVector txt, TSQuery query, int method)
 		return 0.0;
 	}
 
-	MemSet(&ext, 0, sizeof(CoverExt));
+	memset(&ext, 0, sizeof(CoverExt));
 	while (Cover(doc, doclen, &qr, &ext))
 	{
 		double		Cpos = 0.0;
diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c
index 73e41e0808..b3541908e2 100644
--- a/src/backend/utils/adt/varbit.c
+++ b/src/backend/utils/adt/varbit.c
@@ -1419,7 +1419,7 @@ bitshiftleft(PG_FUNCTION_ARGS)
 	/* If we shifted all the bits out, return an all-zero string */
 	if (shft >= VARBITLEN(arg))
 	{
-		MemSet(r, 0, VARBITBYTES(arg));
+		memset(r, 0, VARBITBYTES(arg));
 		PG_RETURN_VARBIT_P(result);
 	}
 
@@ -1432,7 +1432,7 @@ bitshiftleft(PG_FUNCTION_ARGS)
 		/* Special case: we can do a memcpy */
 		len = VARBITBYTES(arg) - byte_shift;
 		memcpy(r, p, len);
-		MemSet(r + len, 0, byte_shift);
+		memset(r + len, 0, byte_shift);
 	}
 	else
 	{
@@ -1486,7 +1486,7 @@ bitshiftright(PG_FUNCTION_ARGS)
 	/* If we shifted all the bits out, return an all-zero string */
 	if (shft >= VARBITLEN(arg))
 	{
-		MemSet(r, 0, VARBITBYTES(arg));
+		memset(r, 0, VARBITBYTES(arg));
 		PG_RETURN_VARBIT_P(result);
 	}
 
@@ -1495,7 +1495,7 @@ bitshiftright(PG_FUNCTION_ARGS)
 	p = VARBITS(arg);
 
 	/* Set the first part of the result to 0 */
-	MemSet(r, 0, byte_shift);
+	memset(r, 0, byte_shift);
 	r += byte_shift;
 
 	if (ishift == 0)
diff --git a/src/backend/utils/cache/relfilenodemap.c b/src/backend/utils/cache/relfilenodemap.c
index 70c323c720..5dbf3c0b7d 100644
--- a/src/backend/utils/cache/relfilenodemap.c
+++ b/src/backend/utils/cache/relfilenodemap.c
@@ -95,7 +95,7 @@ InitializeRelfilenodeMap(void)
 		CreateCacheMemoryContext();
 
 	/* build skey */
-	MemSet(&relfilenode_skey, 0, sizeof(relfilenode_skey));
+	memset(&relfilenode_skey, 0, sizeof(relfilenode_skey));
 
 	for (i = 0; i < 2; i++)
 	{
@@ -153,7 +153,7 @@ RelidByRelfilenode(Oid reltablespace, Oid relfilenode)
 	if (reltablespace == MyDatabaseTableSpace)
 		reltablespace = 0;
 
-	MemSet(&key, 0, sizeof(key));
+	memset(&key, 0, sizeof(key));
 	key.reltablespace = reltablespace;
 	key.relfilenode = relfilenode;
 
diff --git a/src/backend/utils/cache/ts_cache.c b/src/backend/utils/cache/ts_cache.c
index 24808dfbb1..fbb4df7bf2 100644
--- a/src/backend/utils/cache/ts_cache.c
+++ b/src/backend/utils/cache/ts_cache.c
@@ -176,7 +176,7 @@ lookup_ts_parser_cache(Oid prsId)
 			Assert(!found);		/* it wasn't there a moment ago */
 		}
 
-		MemSet(entry, 0, sizeof(TSParserCacheEntry));
+		memset(entry, 0, sizeof(TSParserCacheEntry));
 		entry->prsId = prsId;
 		entry->startOid = prs->prsstart;
 		entry->tokenOid = prs->prstoken;
@@ -306,7 +306,7 @@ lookup_ts_dictionary_cache(Oid dictId)
 			MemoryContextCopyAndSetIdentifier(saveCtx, NameStr(dict->dictname));
 		}
 
-		MemSet(entry, 0, sizeof(TSDictionaryCacheEntry));
+		memset(entry, 0, sizeof(TSDictionaryCacheEntry));
 		entry->dictId = dictId;
 		entry->dictCtx = saveCtx;
 
@@ -455,7 +455,7 @@ lookup_ts_config_cache(Oid cfgId)
 			}
 		}
 
-		MemSet(entry, 0, sizeof(TSConfigCacheEntry));
+		memset(entry, 0, sizeof(TSConfigCacheEntry));
 		entry->cfgId = cfgId;
 		entry->prsId = cfg->cfgparser;
 
@@ -468,7 +468,7 @@ lookup_ts_config_cache(Oid cfgId)
 		 * see the entries in maptokentype order, and in mapseqno order for
 		 * each token type, even though we didn't explicitly ask for that.
 		 */
-		MemSet(maplists, 0, sizeof(maplists));
+		memset(maplists, 0, sizeof(maplists));
 		maxtokentype = 0;
 		ndicts = 0;
 
diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c
index 808f9ebd0d..0fe0255b02 100644
--- a/src/backend/utils/cache/typcache.c
+++ b/src/backend/utils/cache/typcache.c
@@ -396,7 +396,7 @@ lookup_type_cache(Oid type_id, int flags)
 												  HASH_ENTER, &found);
 		Assert(!found);			/* it wasn't there a moment ago */
 
-		MemSet(typentry, 0, sizeof(TypeCacheEntry));
+		memset(typentry, 0, sizeof(TypeCacheEntry));
 
 		/* These fields can never change, by definition */
 		typentry->type_id = type_id;
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 55ee5423af..e1f4aa302b 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -443,7 +443,7 @@ errstart(int elevel, const char *domain)
 
 	/* Initialize data for this error frame */
 	edata = &errordata[errordata_stack_depth];
-	MemSet(edata, 0, sizeof(ErrorData));
+	memset(edata, 0, sizeof(ErrorData));
 	edata->elevel = elevel;
 	edata->output_to_server = output_to_server;
 	edata->output_to_client = output_to_client;
@@ -1476,7 +1476,7 @@ format_elog_string(const char *fmt,...)
 
 	/* Initialize a mostly-dummy error frame */
 	edata = &errdata;
-	MemSet(edata, 0, sizeof(ErrorData));
+	memset(edata, 0, sizeof(ErrorData));
 	/* the default text domain is the backend's */
 	edata->domain = save_format_domain ? save_format_domain : PG_TEXTDOMAIN("postgres");
 	/* set the errno to be used to interpret %m */
@@ -1872,7 +1872,7 @@ GetErrorContextStack(void)
 	 * Things look good so far, so initialize our error frame
 	 */
 	edata = &errordata[errordata_stack_depth];
-	MemSet(edata, 0, sizeof(ErrorData));
+	memset(edata, 0, sizeof(ErrorData));
 
 	/*
 	 * Set up assoc_context to be the caller's context, so any allocations
diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c
index 7f9ea97280..ee69dc8bf2 100644
--- a/src/backend/utils/fmgr/dfmgr.c
+++ b/src/backend/utils/fmgr/dfmgr.c
@@ -228,7 +228,7 @@ internal_load_library(const char *libname)
 					(errcode(ERRCODE_OUT_OF_MEMORY),
 					 errmsg("out of memory")));
 
-		MemSet(file_scanner, 0, offsetof(DynamicFileList, filename));
+		memset(file_scanner, 0, offsetof(DynamicFileList, filename));
 		strcpy(file_scanner->filename, libname);
 		file_scanner->device = stat_buf.st_dev;
 #ifndef WIN32
diff --git a/src/backend/utils/hash/dynahash.c b/src/backend/utils/hash/dynahash.c
index 3babde8d70..27c5f3e80f 100644
--- a/src/backend/utils/hash/dynahash.c
+++ b/src/backend/utils/hash/dynahash.c
@@ -388,7 +388,7 @@ hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
 
 	/* Initialize the hash header, plus a copy of the table name */
 	hashp = (HTAB *) DynaHashAlloc(sizeof(HTAB) + strlen(tabname) + 1);
-	MemSet(hashp, 0, sizeof(HTAB));
+	memset(hashp, 0, sizeof(HTAB));
 
 	hashp->tabname = (char *) (hashp + 1);
 	strcpy(hashp->tabname, tabname);
@@ -627,7 +627,7 @@ hdefault(HTAB *hashp)
 {
 	HASHHDR    *hctl = hashp->hctl;
 
-	MemSet(hctl, 0, sizeof(HASHHDR));
+	memset(hctl, 0, sizeof(HASHHDR));
 
 	hctl->dsize = DEF_DIRSIZE;
 	hctl->nsegs = 0;
@@ -1666,7 +1666,7 @@ dir_realloc(HTAB *hashp)
 	if (p != NULL)
 	{
 		memcpy(p, old_p, old_dirsize);
-		MemSet(((char *) p) + old_dirsize, 0, new_dirsize - old_dirsize);
+		memset(((char *) p) + old_dirsize, 0, new_dirsize - old_dirsize);
 		hashp->dir = p;
 		hashp->hctl->dsize = new_dsize;
 
@@ -1692,7 +1692,7 @@ seg_alloc(HTAB *hashp)
 	if (!segp)
 		return NULL;
 
-	MemSet(segp, 0, sizeof(HASHBUCKET) * hashp->ssize);
+	memset(segp, 0, sizeof(HASHBUCKET) * hashp->ssize);
 
 	return segp;
 }
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 8e9b71375c..2169604b02 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -11936,7 +11936,7 @@ check_wal_consistency_checking(char **newval, void **extra, GucSource source)
 	bool		newwalconsistency[RM_MAX_ID + 1];
 
 	/* Initialize the array */
-	MemSet(newwalconsistency, 0, (RM_MAX_ID + 1) * sizeof(bool));
+	memset(newwalconsistency, 0, (RM_MAX_ID + 1) * sizeof(bool));
 
 	/* Need a modifiable copy of string */
 	rawstring = pstrdup(*newval);
diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.c
index ec314c03f5..ca05b180c9 100644
--- a/src/backend/utils/misc/ps_status.c
+++ b/src/backend/utils/misc/ps_status.c
@@ -393,7 +393,7 @@ set_ps_display(const char *activity)
 #ifdef PS_USE_CLOBBER_ARGV
 	/* pad unused memory; need only clobber remainder of old status string */
 	if (last_status_len > ps_buffer_cur_len)
-		MemSet(ps_buffer + ps_buffer_cur_len, PS_PADDING,
+		memset(ps_buffer + ps_buffer_cur_len, PS_PADDING,
 			   last_status_len - ps_buffer_cur_len);
 	last_status_len = ps_buffer_cur_len;
 #endif							/* PS_USE_CLOBBER_ARGV */
diff --git a/src/backend/utils/misc/timeout.c b/src/backend/utils/misc/timeout.c
index 6f5e08bc30..16ff6250b1 100644
--- a/src/backend/utils/misc/timeout.c
+++ b/src/backend/utils/misc/timeout.c
@@ -216,7 +216,7 @@ schedule_alarm(TimestampTz now)
 		long		secs;
 		int			usecs;
 
-		MemSet(&timeval, 0, sizeof(struct itimerval));
+		memset(&timeval, 0, sizeof(struct itimerval));
 
 		/*
 		 * If we think there's a signal pending, but current time is more than
diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c
index d549f66d4a..25ced094b9 100644
--- a/src/backend/utils/mmgr/portalmem.c
+++ b/src/backend/utils/mmgr/portalmem.c
@@ -1152,7 +1152,7 @@ pg_cursor(PG_FUNCTION_ARGS)
 		if (!portal->visible)
 			continue;
 
-		MemSet(nulls, 0, sizeof(nulls));
+		memset(nulls, 0, sizeof(nulls));
 
 		values[0] = CStringGetTextDatum(portal->name);
 		values[1] = CStringGetTextDatum(portal->sourceText);
diff --git a/src/backend/utils/sort/logtape.c b/src/backend/utils/sort/logtape.c
index c384f98e13..4a6dbb91ca 100644
--- a/src/backend/utils/sort/logtape.c
+++ b/src/backend/utils/sort/logtape.c
@@ -254,7 +254,7 @@ ltsWriteBlock(LogicalTapeSet *lts, long blocknum, void *buffer)
 	{
 		PGAlignedBlock zerobuf;
 
-		MemSet(zerobuf.data, 0, sizeof(zerobuf));
+		memset(zerobuf.data, 0, sizeof(zerobuf));
 
 		ltsWriteBlock(lts, lts->nBlocksWritten, zerobuf.data);
 	}
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index 4adb170d46..3f112e8082 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -457,7 +457,7 @@ reached_end_position(XLogRecPtr segendpos, uint32 timeline,
 		FD_ZERO(&fds);
 		FD_SET(bgpipe[0], &fds);
 
-		MemSet(&tv, 0, sizeof(tv));
+		memset(&tv, 0, sizeof(tv));
 
 		r = select(bgpipe[0] + 1, &fds, NULL, NULL, &tv);
 		if (r == 1)
@@ -466,7 +466,7 @@ reached_end_position(XLogRecPtr segendpos, uint32 timeline,
 			uint32		hi,
 						lo;
 
-			MemSet(xlogend, 0, sizeof(xlogend));
+			memset(xlogend, 0, sizeof(xlogend));
 			r = read(bgpipe[0], xlogend, sizeof(xlogend) - 1);
 			if (r < 0)
 				pg_fatal("could not read from ready pipe: %m");
@@ -532,7 +532,7 @@ LogStreamerMain(logstreamer_param *param)
 
 	in_log_streamer = true;
 
-	MemSet(&stream, 0, sizeof(stream));
+	memset(&stream, 0, sizeof(stream));
 	stream.startpos = param->startptr;
 	stream.timeline = param->timeline;
 	stream.sysidentifier = param->sysidentifier;
@@ -1961,7 +1961,7 @@ BaseBackup(char *compression_algorithm, char *compression_detail,
 	else
 		starttli = latesttli;
 	PQclear(res);
-	MemSet(xlogend, 0, sizeof(xlogend));
+	memset(xlogend, 0, sizeof(xlogend));
 
 	if (verbose && includewal != NO_WAL)
 		pg_log_info("write-ahead log start point: %s on timeline %u",
diff --git a/src/bin/pg_basebackup/pg_receivewal.c b/src/bin/pg_basebackup/pg_receivewal.c
index ea3902c971..c621588ceb 100644
--- a/src/bin/pg_basebackup/pg_receivewal.c
+++ b/src/bin/pg_basebackup/pg_receivewal.c
@@ -567,7 +567,7 @@ StreamLog(void)
 	StreamCtl	stream;
 	char	   *sysidentifier;
 
-	MemSet(&stream, 0, sizeof(stream));
+	memset(&stream, 0, sizeof(stream));
 
 	/*
 	 * Connect in replication mode to the server
diff --git a/src/bin/pg_basebackup/walmethods.c b/src/bin/pg_basebackup/walmethods.c
index cc292718da..bf838ef80e 100644
--- a/src/bin/pg_basebackup/walmethods.c
+++ b/src/bin/pg_basebackup/walmethods.c
@@ -1114,7 +1114,7 @@ tar_close(Walfile f, WalCloseMethod method)
 	{
 		char		zerobuf[TAR_BLOCK_SIZE];
 
-		MemSet(zerobuf, 0, padding);
+		memset(zerobuf, 0, padding);
 		if (tar_write(f, zerobuf, padding) != padding)
 			return -1;
 	}
@@ -1234,7 +1234,7 @@ tar_finish(void)
 	}
 
 	/* A tarfile always ends with two empty blocks */
-	MemSet(zerobuf, 0, sizeof(zerobuf));
+	memset(zerobuf, 0, sizeof(zerobuf));
 	if (tar_data->compression_algorithm == PG_COMPRESSION_NONE)
 	{
 		errno = 0;
diff --git a/src/common/fe_memutils.c b/src/common/fe_memutils.c
index 21fcce5430..9e433db245 100644
--- a/src/common/fe_memutils.c
+++ b/src/common/fe_memutils.c
@@ -39,7 +39,7 @@ pg_malloc_internal(size_t size, int flags)
 	}
 
 	if ((flags & MCXT_ALLOC_ZERO) != 0)
-		MemSet(tmp, 0, size);
+		memset(tmp, 0, size);
 	return tmp;
 }
 
diff --git a/src/common/ip.c b/src/common/ip.c
index cd73d49679..a574b58de2 100644
--- a/src/common/ip.c
+++ b/src/common/ip.c
@@ -171,7 +171,7 @@ getaddrinfo_unix(const char *path, const struct addrinfo *hintsp,
 
 	*result = NULL;
 
-	MemSet(&hints, 0, sizeof(hints));
+	memset(&hints, 0, sizeof(hints));
 
 	if (strlen(path) >= sizeof(unp->sun_path))
 		return EAI_FAIL;
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 6e936bbff3..5cdfc0bb40 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -2378,7 +2378,7 @@ keep_going:						/* We will come back to here until there is
 		ch = &conn->connhost[conn->whichhost];
 
 		/* Initialize hint structure */
-		MemSet(&hint, 0, sizeof(hint));
+		memset(&hint, 0, sizeof(hint));
 		hint.ai_socktype = SOCK_STREAM;
 		conn->addrlist_family = hint.ai_family = AF_UNSPEC;
 
@@ -3977,7 +3977,7 @@ makeEmptyPGconn(void)
 		return conn;
 
 	/* Zero all pointers and booleans */
-	MemSet(conn, 0, sizeof(PGconn));
+	memset(conn, 0, sizeof(PGconn));
 
 	/* install default notice hooks */
 	conn->noticeHooks.noticeRec = defaultNoticeReceiver;
@@ -5545,7 +5545,7 @@ conninfo_init(PQExpBuffer errorMessage)
 		memcpy(opt_dest, cur_opt, sizeof(PQconninfoOption));
 		opt_dest++;
 	}
-	MemSet(opt_dest, 0, sizeof(PQconninfoOption));
+	memset(opt_dest, 0, sizeof(PQconninfoOption));
 
 	return options;
 }
diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c
index 075a5ed85b..b59df84baf 100644
--- a/src/interfaces/libpq/fe-lobj.c
+++ b/src/interfaces/libpq/fe-lobj.c
@@ -884,7 +884,7 @@ lo_initialize(PGconn *conn)
 							 libpq_gettext("out of memory\n"));
 		return -1;
 	}
-	MemSet((char *) lobjfuncs, 0, sizeof(PGlobjfuncs));
+	memset((char *) lobjfuncs, 0, sizeof(PGlobjfuncs));
 
 	/*
 	 * Execute the query to get all the functions at once.  (Not all of them
diff --git a/src/interfaces/libpq/fe-protocol3.c b/src/interfaces/libpq/fe-protocol3.c
index 10c76daf6e..a8321fae0a 100644
--- a/src/interfaces/libpq/fe-protocol3.c
+++ b/src/interfaces/libpq/fe-protocol3.c
@@ -557,7 +557,7 @@ getRowDescriptions(PGconn *conn, int msgLength)
 			errmsg = NULL;		/* means "out of memory", see below */
 			goto advance_and_error;
 		}
-		MemSet(result->attDescs, 0, nfields * sizeof(PGresAttDesc));
+		memset(result->attDescs, 0, nfields * sizeof(PGresAttDesc));
 	}
 
 	/* result->binary is true only if ALL columns are binary */
@@ -703,7 +703,7 @@ getParamDescriptions(PGconn *conn, int msgLength)
 			pqResultAlloc(result, nparams * sizeof(PGresParamDesc), true);
 		if (!result->paramDescs)
 			goto advance_and_error;
-		MemSet(result->paramDescs, 0, nparams * sizeof(PGresParamDesc));
+		memset(result->paramDescs, 0, nparams * sizeof(PGresParamDesc));
 	}
 
 	/* get parameter info */
@@ -1529,7 +1529,7 @@ getCopyStart(PGconn *conn, ExecStatusType copytype)
 			pqResultAlloc(result, nfields * sizeof(PGresAttDesc), true);
 		if (!result->attDescs)
 			goto failure;
-		MemSet(result->attDescs, 0, nfields * sizeof(PGresAttDesc));
+		memset(result->attDescs, 0, nfields * sizeof(PGresAttDesc));
 	}
 
 	for (i = 0; i < nfields; i++)
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index edb93ec1c4..25d98a81c8 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -1844,7 +1844,7 @@ plperl_call_handler(PG_FUNCTION_ARGS)
 	plperl_call_data this_call_data;
 
 	/* Initialize current-call status record */
-	MemSet(&this_call_data, 0, sizeof(this_call_data));
+	memset(&this_call_data, 0, sizeof(this_call_data));
 	this_call_data.fcinfo = fcinfo;
 
 	PG_TRY();
@@ -1890,7 +1890,7 @@ plperl_inline_handler(PG_FUNCTION_ARGS)
 	ErrorContextCallback pl_error_context;
 
 	/* Initialize current-call status record */
-	MemSet(&this_call_data, 0, sizeof(this_call_data));
+	memset(&this_call_data, 0, sizeof(this_call_data));
 
 	/* Set up a callback for error reporting */
 	pl_error_context.callback = plperl_inline_callback;
@@ -1903,9 +1903,9 @@ plperl_inline_handler(PG_FUNCTION_ARGS)
 	 * plperl_call_perl_func().  In particular note that this sets things up
 	 * with no arguments passed, and a result type of VOID.
 	 */
-	MemSet(fake_fcinfo, 0, SizeForFunctionCallInfo(0));
-	MemSet(&flinfo, 0, sizeof(flinfo));
-	MemSet(&desc, 0, sizeof(desc));
+	memset(fake_fcinfo, 0, SizeForFunctionCallInfo(0));
+	memset(&flinfo, 0, sizeof(flinfo));
+	memset(&desc, 0, sizeof(desc));
 	fake_fcinfo->flinfo = &flinfo;
 	flinfo.fn_oid = InvalidOid;
 	flinfo.fn_mcxt = CurrentMemoryContext;
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index b791c23f06..d7053ad914 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
@@ -2455,7 +2455,7 @@ compute_function_hashkey(FunctionCallInfo fcinfo,
 						 bool forValidator)
 {
 	/* Make sure any unused bytes of the struct are zero */
-	MemSet(hashkey, 0, sizeof(PLpgSQL_func_hashkey));
+	memset(hashkey, 0, sizeof(PLpgSQL_func_hashkey));
 
 	/* get function OID */
 	hashkey->funcOid = fcinfo->flinfo->fn_oid;
diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c
index 190d286f1c..d51de407e1 100644
--- a/src/pl/plpgsql/src/pl_handler.c
+++ b/src/pl/plpgsql/src/pl_handler.c
@@ -340,8 +340,8 @@ plpgsql_inline_handler(PG_FUNCTION_ARGS)
 	 * plpgsql_exec_function().  In particular note that this sets things up
 	 * with no arguments passed.
 	 */
-	MemSet(fake_fcinfo, 0, SizeForFunctionCallInfo(0));
-	MemSet(&flinfo, 0, sizeof(flinfo));
+	memset(fake_fcinfo, 0, SizeForFunctionCallInfo(0));
+	memset(&flinfo, 0, sizeof(flinfo));
 	fake_fcinfo->flinfo = &flinfo;
 	flinfo.fn_oid = InvalidOid;
 	flinfo.fn_mcxt = CurrentMemoryContext;
@@ -517,20 +517,20 @@ plpgsql_validator(PG_FUNCTION_ARGS)
 		 * Set up a fake fcinfo with just enough info to satisfy
 		 * plpgsql_compile().
 		 */
-		MemSet(fake_fcinfo, 0, SizeForFunctionCallInfo(0));
-		MemSet(&flinfo, 0, sizeof(flinfo));
+		memset(fake_fcinfo, 0, SizeForFunctionCallInfo(0));
+		memset(&flinfo, 0, sizeof(flinfo));
 		fake_fcinfo->flinfo = &flinfo;
 		flinfo.fn_oid = funcoid;
 		flinfo.fn_mcxt = CurrentMemoryContext;
 		if (is_dml_trigger)
 		{
-			MemSet(&trigdata, 0, sizeof(trigdata));
+			memset(&trigdata, 0, sizeof(trigdata));
 			trigdata.type = T_TriggerData;
 			fake_fcinfo->context = (Node *) &trigdata;
 		}
 		else if (is_event_trigger)
 		{
-			MemSet(&etrigdata, 0, sizeof(etrigdata));
+			memset(&etrigdata, 0, sizeof(etrigdata));
 			etrigdata.type = T_EventTriggerData;
 			fake_fcinfo->context = (Node *) &etrigdata;
 		}
diff --git a/src/pl/plpython/plpy_main.c b/src/pl/plpython/plpy_main.c
index 0bce106495..dc707da034 100644
--- a/src/pl/plpython/plpy_main.c
+++ b/src/pl/plpython/plpy_main.c
@@ -277,13 +277,13 @@ plpython3_inline_handler(PG_FUNCTION_ARGS)
 	if (SPI_connect_ext(codeblock->atomic ? 0 : SPI_OPT_NONATOMIC) != SPI_OK_CONNECT)
 		elog(ERROR, "SPI_connect failed");
 
-	MemSet(fcinfo, 0, SizeForFunctionCallInfo(0));
-	MemSet(&flinfo, 0, sizeof(flinfo));
+	memset(fcinfo, 0, SizeForFunctionCallInfo(0));
+	memset(&flinfo, 0, sizeof(flinfo));
 	fake_fcinfo->flinfo = &flinfo;
 	flinfo.fn_oid = InvalidOid;
 	flinfo.fn_mcxt = CurrentMemoryContext;
 
-	MemSet(&proc, 0, sizeof(PLyProcedure));
+	memset(&proc, 0, sizeof(PLyProcedure));
 	proc.mcxt = AllocSetContextCreate(TopMemoryContext,
 									  "__plpython_inline_block",
 									  ALLOCSET_DEFAULT_SIZES);
diff --git a/src/port/snprintf.c b/src/port/snprintf.c
index abb1c59770..2e929e4e8e 100644
--- a/src/port/snprintf.c
+++ b/src/port/snprintf.c
@@ -761,7 +761,7 @@ find_arguments(const char *format, va_list args,
 
 	/* Initialize to "no dollar arguments known" */
 	last_dollar = 0;
-	MemSet(argtypes, 0, sizeof(argtypes));
+	memset(argtypes, 0, sizeof(argtypes));
 
 	/*
 	 * This loop must accept the same format strings as the one in dopr().
diff --git a/src/test/modules/test_predtest/test_predtest.c b/src/test/modules/test_predtest/test_predtest.c
index 3b19e0eadc..1d2b1d4956 100644
--- a/src/test/modules/test_predtest/test_predtest.c
+++ b/src/test/modules/test_predtest/test_predtest.c
@@ -204,7 +204,7 @@ test_predtest(PG_FUNCTION_ARGS)
 					   "w_r_holds", BOOLOID, -1, 0);
 	tupdesc = BlessTupleDesc(tupdesc);
 
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(nulls, 0, sizeof(nulls));
 	values[0] = BoolGetDatum(strong_implied_by);
 	values[1] = BoolGetDatum(weak_implied_by);
 	values[2] = BoolGetDatum(strong_refuted_by);
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c
index ba3532a51e..e13db0d683 100644
--- a/src/test/regress/regress.c
+++ b/src/test/regress/regress.c
@@ -1199,7 +1199,7 @@ test_enc_conversion(PG_FUNCTION_ARGS)
 		pfree(dst);
 	}
 
-	MemSet(nulls, 0, sizeof(nulls));
+	memset(nulls, 0, sizeof(nulls));
 	values[0] = Int32GetDatum(convertedbytes);
 	values[1] = PointerGetDatum(retval);
 	tuple = heap_form_tuple(tupdesc, values, nulls);
