Replace memcpy/memset with std::copy_n/std::fill_n.
Replace memcpy/memset with std::copy_n/std::fill_n.


--- a/src/in_2sf/XSFPlayer_2SF.cpp
+++ b/src/in_2sf/XSFPlayer_2SF.cpp
@@ -88,7 +88,7 @@
 	uint32_t num_bytes = num_samples << 2;
 	if (num_bytes > sndifwork.bufferbytes)
 		num_bytes = sndifwork.bufferbytes;
-	memcpy(&sndifwork.buf[0], buffer, num_bytes);
+	std::copy_n(reinterpret_cast<uint8_t *>(buffer), num_bytes, &sndifwork.buf[0]);
 	sndifwork.filled = num_bytes;
 	sndifwork.used = 0;
 }
@@ -125,7 +125,7 @@
 		this->rom.resize(finalSize + 10, 0);
 	else if (this->rom.size() < size + offset)
 		this->rom.resize(offset + finalSize + 10);
-	memcpy(&this->rom[offset], &section[8], size);
+	std::copy_n(&section[8], size, &this->rom[offset]);
 }
 
 bool XSFPlayer_2SF::Map2SF(XSFFile *xSFToLoad)
@@ -263,7 +263,7 @@
 		{
 			if (remainbytes > bytes)
 			{
-				memcpy(&buf[offset], &sndifwork.buf[sndifwork.used], bytes);
+				std::copy_n(&sndifwork.buf[sndifwork.used], bytes, &buf[offset]);
 				sndifwork.used += bytes;
 				offset += bytes;
 				remainbytes -= bytes;
@@ -272,7 +272,7 @@
 			}
 			else
 			{
-				memcpy(&buf[offset], &sndifwork.buf[sndifwork.used], remainbytes);
+				std::copy_n(&sndifwork.buf[sndifwork.used], remainbytes, &buf[offset]);
 				sndifwork.used += remainbytes;
 				offset += remainbytes;
 				bytes -= remainbytes;

--- a/src/in_gsf/XSFPlayer_GSF.cpp
+++ b/src/in_gsf/XSFPlayer_GSF.cpp
@@ -58,7 +58,7 @@
 	if (static_cast<size_t>(l) > loaderwork.rom.size())
 		l = loaderwork.rom.size();
 	if (l)
-		memcpy(d, &loaderwork.rom[0], l);
+		std::copy_n(&loaderwork.rom[0], l, d);
 	s = l;
 	return l;
 }
@@ -104,7 +104,7 @@
 			length = buffer.len - buffer.fil;
 		if (length > 0)
 		{
-			memcpy(&buffer.buf[buffer.fil], finalWave, length);
+			std::copy_n(reinterpret_cast<uint8_t *>(finalWave), length, &buffer.buf[buffer.fil]);
 			buffer.fil += length;
 		}
 	}
@@ -131,7 +131,7 @@
 		data.resize(finalSize + 10, 0);
 	else if (data.size() < size + offset)
 		data.resize(offset + finalSize + 10);
-	memcpy(&data[offset], &section[12], size);
+	std::copy_n(&section[12], size, &data[offset]);
 }
 
 static bool MapGSF(XSFFile *xSF, int level)
@@ -241,7 +241,7 @@
 		unsigned len = remainbytes;
 		if (len > bytes)
 			len = bytes;
-		memcpy(&buf[offset], &buffer.buf[buffer.cur], len);
+		std::copy_n(&buffer.buf[buffer.cur], len, &buf[offset]);
 		bytes -= len;
 		offset += len;
 		buffer.cur += len;

--- a/src/in_ncsf/SSEQPlayer/INFOEntry.cpp
+++ b/src/in_ncsf/SSEQPlayer/INFOEntry.cpp
@@ -27,7 +27,7 @@
 
 INFOEntryBANK::INFOEntryBANK() : fileID(0)
 {
-	memset(this->waveArc, 0, sizeof(this->waveArc));
+	std::fill_n(&this->waveArc[0], 4, 0);
 }
 
 void INFOEntryBANK::Read(PseudoFile &file)

--- a/src/in_ncsf/SSEQPlayer/NDSStdHeader.cpp
+++ b/src/in_ncsf/SSEQPlayer/NDSStdHeader.cpp
@@ -11,7 +11,7 @@
 
 NDSStdHeader::NDSStdHeader() : magic(0)
 {
-	memset(this->type, 0, sizeof(this->type));
+	std::fill_n(&this->type[0], 4, 0);
 }
 
 void NDSStdHeader::Read(PseudoFile &file)

--- a/src/in_ncsf/SSEQPlayer/Player.cpp
+++ b/src/in_ncsf/SSEQPlayer/Player.cpp
@@ -13,13 +13,13 @@
 Player::Player() : prio(0), nTracks(0), tempo(0), tempoCount(0), tempoRate(0), masterVol(0), sseqVol(0), sseq(nullptr), allowedChannels(0), sampleRate(0),
 	interpolation(INTERPOLATION_NONE)
 {
-	memset(this->trackIds, 0, sizeof(this->trackIds));
+	std::fill_n(&this->trackIds[0], FSS_TRACKCOUNT, 0);
 	for (int8_t i = 0; i < 16; ++i)
 	{
 		this->channels[i].chnId = i;
 		this->channels[i].ply = this;
 	}
-	memset(this->variables, -1, sizeof(this->variables));
+	std::fill_n(&this->variables[0], 32, -1);
 }
 
 // Original FSS Function: Player_Setup
@@ -49,7 +49,7 @@
 	this->tempoCount = 0;
 	this->tempoRate = 0x100;
 	this->masterVol = 0; // this is actually the highest level
-	memset(this->variables, -1, sizeof(this->variables));
+	std::fill_n(&this->variables[0], 32, -1);
 }
 
 // Original FSS Function: Player_FreeTracks

--- a/src/in_ncsf/SSEQPlayer/SBNK.cpp
+++ b/src/in_ncsf/SSEQPlayer/SBNK.cpp
@@ -81,7 +81,7 @@
 
 SBNK::SBNK(const std::string &fn) : filename(fn), instruments(), info()
 {
-	memset(this->waveArc, 0, sizeof(this->waveArc));
+	std::fill_n(&this->waveArc[0], 4, nullptr);
 }
 
 void SBNK::Read(PseudoFile &file)

--- a/src/in_ncsf/SSEQPlayer/Track.cpp
+++ b/src/in_ncsf/SSEQPlayer/Track.cpp
@@ -38,7 +38,7 @@
 	this->startPos = this->pos = nullptr;
 	std::fill_n(&this->stack[0], FSS_TRACKSTACKSIZE, StackValue());
 	this->stackPos = 0;
-	memset(this->loopCount, 0, sizeof(this->loopCount));
+	std::fill_n(&this->loopCount[0], FSS_TRACKSTACKSIZE, 0);
 	this->overriding() = false;
 	this->lastComparisonResult = true;
 

--- a/src/in_ncsf/SSEQPlayer/common.h
+++ b/src/in_ncsf/SSEQPlayer/common.h
@@ -43,7 +43,7 @@
 
 	template<size_t N> void ReadLE(uint8_t arr[N])
 	{
-		memcpy(&arr[0], &(*this->data)[this->pos], N);
+		std::copy_n(&(*this->data)[this->pos], N, &arr[0]);
 		this->pos += N;
 	}
 
@@ -55,7 +55,7 @@
 
 	void ReadLE(std::vector<uint8_t> &arr)
 	{
-		memcpy(&arr[0], &(*this->data)[this->pos], arr.size());
+		std::copy_n(&(*this->data)[this->pos], arr.size(), &arr[0]);
 		this->pos += arr.size();
 	}
 

--- a/src/in_ncsf/XSFPlayer_NCSF.cpp
+++ b/src/in_ncsf/XSFPlayer_NCSF.cpp
@@ -43,7 +43,7 @@
 		this->sdatData.resize(finalSize, 0);
 	else if (this->sdatData.size() < size)
 		this->sdatData.resize(finalSize);
-	memcpy(&this->sdatData[0], &section[0], size);
+	std::copy_n(&section[0], size, &this->sdatData[0]);
 }
 
 bool XSFPlayer_NCSF::MapNCSF(XSFFile *xSFToLoad)

--- a/src/in_xsf_framework/DialogBuilder.cpp
+++ b/src/in_xsf_framework/DialogBuilder.cpp
@@ -134,7 +134,7 @@
 	*reinterpret_cast<uint16_t *>(&data[16]) = static_cast<uint16_t>(this->id);
 	*reinterpret_cast<uint16_t *>(&data[18]) = 0xFFFF;
 	*reinterpret_cast<uint16_t *>(&data[20]) = 0x0080;
-	memcpy(reinterpret_cast<wchar_t *>(&data[22]), this->groupName.c_str(), this->groupName.length() * sizeof(wchar_t));
+	std::copy_n(this->groupName.c_str(), this->groupName.length(), reinterpret_cast<wchar_t *>(&data[22]));
 
 	std::for_each(this->controls.begin(), this->controls.end(), [&](const std::unique_ptr<DialogControl> &control)
 	{
@@ -175,7 +175,7 @@
 	*reinterpret_cast<uint16_t *>(&data[16]) = static_cast<uint16_t>(this->id);
 	*reinterpret_cast<uint16_t *>(&data[18]) = 0xFFFF;
 	*reinterpret_cast<uint16_t *>(&data[20]) = this->type;
-	memcpy(reinterpret_cast<wchar_t *>(&data[22]), this->label.c_str(), this->label.length() * sizeof(wchar_t));
+	std::copy_n(this->label.c_str(), this->label.length(), reinterpret_cast<wchar_t *>(&data[22]));
 
 	return data;
 }
@@ -346,11 +346,11 @@
 	*reinterpret_cast<uint16_t *>(&this->templateData[8]) = controlCount;
 	*reinterpret_cast<uint16_t *>(&this->templateData[14]) = this->size.width;
 	*reinterpret_cast<uint16_t *>(&this->templateData[16]) = this->size.height;
-	memcpy(reinterpret_cast<wchar_t *>(&this->templateData[22]), this->title.c_str(), this->title.length() * sizeof(wchar_t));
+	std::copy_n(this->title.c_str(), this->title.length(), reinterpret_cast<wchar_t *>(&this->templateData[22]));
 	if (!this->fontName.empty())
 	{
 		*reinterpret_cast<uint16_t *>(&this->templateData[22 + sizeof(wchar_t) * (this->title.length() + 1)]) = this->fontSizeInPts;
-		memcpy(reinterpret_cast<wchar_t *>(&this->templateData[24 + sizeof(wchar_t) * (this->title.length() + 1)]), this->fontName.c_str(), this->fontName.length() * sizeof(wchar_t));
+		std::copy_n(this->fontName.c_str(), this->fontName.length(), reinterpret_cast<wchar_t *>(&this->templateData[24 + sizeof(wchar_t) * (this->title.length() + 1)]));
 	}
 
 	std::for_each(this->controls.begin(), this->controls.end(), [&](const std::unique_ptr<DialogControl> &control)

--- a/src/in_xsf_framework/XSFFile.cpp
+++ b/src/in_xsf_framework/XSFFile.cpp
@@ -128,7 +128,7 @@
 	this->xSFType = PSFHeader[3];
 
 	this->rawData.resize(4);
-	memcpy(&this->rawData[0], PSFHeader, 4);
+	std::copy_n(PSFHeader, 4, &this->rawData[0]);
 
 	if (filesize < 16)
 		throw std::runtime_error("File is too small.");
@@ -150,7 +150,7 @@
 		{
 			this->reservedSection.resize(reservedSize);
 			xSF.read(reinterpret_cast<char *>(&this->reservedSection[0]), reservedSize);
-			memcpy(&this->rawData[16], &this->reservedSection[0], reservedSize);
+			std::copy_n(&this->reservedSection[0], reservedSize, &this->rawData[16]);
 		}
 	}
 
@@ -165,7 +165,7 @@
 		{
 			auto programSectionCompressed = std::vector<uint8_t>(programCompressedSize);
 			xSF.read(reinterpret_cast<char *>(&programSectionCompressed[0]), programCompressedSize);
-			memcpy(&this->rawData[reservedSize + 16], &programSectionCompressed[0], programCompressedSize);
+			std::copy_n(&programSectionCompressed[0], programCompressedSize, &this->rawData[reservedSize + 16]);
 
 			auto programSectionUncompressed = std::vector<uint8_t>(programHeaderSize);
 			unsigned long programUncompressedSize = programHeaderSize;

--- a/src/in_xsf_framework/in_xsf.cpp
+++ b/src/in_xsf_framework/in_xsf.cpp
@@ -488,7 +488,7 @@
 		auto sampleBuffer = std::vector<uint8_t>(576 * NumChannels * (BitsPerSample / 8));
 		unsigned samplesWritten = 0;
 		done = tmpxSFPlayer->FillBuffer(sampleBuffer, samplesWritten);
-		memcpy(&dest[copied], &sampleBuffer[0], samplesWritten * NumChannels * (BitsPerSample / 8));
+		std::copy_n(&sampleBuffer[0], samplesWritten * NumChannels * (BitsPerSample / 8), &dest[copied]);
 		copied += samplesWritten * NumChannels * (BitsPerSample / 8);
 		if (killswitch && *killswitch)
 			break;