| ... | ... |
@@ -88,7 +88,7 @@ static void SNDIFUpdateAudio(int16_t *buffer, uint32_t num_samples) |
| 88 | 88 |
uint32_t num_bytes = num_samples << 2; |
| 89 | 89 |
if (num_bytes > sndifwork.bufferbytes) |
| 90 | 90 |
num_bytes = sndifwork.bufferbytes; |
| 91 |
- memcpy(&sndifwork.buf[0], buffer, num_bytes); |
|
| 91 |
+ std::copy_n(reinterpret_cast<uint8_t *>(buffer), num_bytes, &sndifwork.buf[0]); |
|
| 92 | 92 |
sndifwork.filled = num_bytes; |
| 93 | 93 |
sndifwork.used = 0; |
| 94 | 94 |
} |
| ... | ... |
@@ -125,7 +125,7 @@ void XSFPlayer_2SF::Map2SFSection(const std::vector<uint8_t> §ion) |
| 125 | 125 |
this->rom.resize(finalSize + 10, 0); |
| 126 | 126 |
else if (this->rom.size() < size + offset) |
| 127 | 127 |
this->rom.resize(offset + finalSize + 10); |
| 128 |
- memcpy(&this->rom[offset], §ion[8], size); |
|
| 128 |
+ std::copy_n(§ion[8], size, &this->rom[offset]); |
|
| 129 | 129 |
} |
| 130 | 130 |
|
| 131 | 131 |
bool XSFPlayer_2SF::Map2SF(XSFFile *xSFToLoad) |
| ... | ... |
@@ -263,7 +263,7 @@ void XSFPlayer_2SF::GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, |
| 263 | 263 |
{
|
| 264 | 264 |
if (remainbytes > bytes) |
| 265 | 265 |
{
|
| 266 |
- memcpy(&buf[offset], &sndifwork.buf[sndifwork.used], bytes); |
|
| 266 |
+ std::copy_n(&sndifwork.buf[sndifwork.used], bytes, &buf[offset]); |
|
| 267 | 267 |
sndifwork.used += bytes; |
| 268 | 268 |
offset += bytes; |
| 269 | 269 |
remainbytes -= bytes; |
| ... | ... |
@@ -272,7 +272,7 @@ void XSFPlayer_2SF::GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, |
| 272 | 272 |
} |
| 273 | 273 |
else |
| 274 | 274 |
{
|
| 275 |
- memcpy(&buf[offset], &sndifwork.buf[sndifwork.used], remainbytes); |
|
| 275 |
+ std::copy_n(&sndifwork.buf[sndifwork.used], remainbytes, &buf[offset]); |
|
| 276 | 276 |
sndifwork.used += remainbytes; |
| 277 | 277 |
offset += remainbytes; |
| 278 | 278 |
bytes -= remainbytes; |
| ... | ... |
@@ -58,7 +58,7 @@ int mapgsf(uint8_t *d, int l, int &s) |
| 58 | 58 |
if (static_cast<size_t>(l) > loaderwork.rom.size()) |
| 59 | 59 |
l = loaderwork.rom.size(); |
| 60 | 60 |
if (l) |
| 61 |
- memcpy(d, &loaderwork.rom[0], l); |
|
| 61 |
+ std::copy_n(&loaderwork.rom[0], l, d); |
|
| 62 | 62 |
s = l; |
| 63 | 63 |
return l; |
| 64 | 64 |
} |
| ... | ... |
@@ -104,7 +104,7 @@ public: |
| 104 | 104 |
length = buffer.len - buffer.fil; |
| 105 | 105 |
if (length > 0) |
| 106 | 106 |
{
|
| 107 |
- memcpy(&buffer.buf[buffer.fil], finalWave, length); |
|
| 107 |
+ std::copy_n(reinterpret_cast<uint8_t *>(finalWave), length, &buffer.buf[buffer.fil]); |
|
| 108 | 108 |
buffer.fil += length; |
| 109 | 109 |
} |
| 110 | 110 |
} |
| ... | ... |
@@ -131,7 +131,7 @@ static void MapGSFSection(const std::vector<uint8_t> §ion, int level) |
| 131 | 131 |
data.resize(finalSize + 10, 0); |
| 132 | 132 |
else if (data.size() < size + offset) |
| 133 | 133 |
data.resize(offset + finalSize + 10); |
| 134 |
- memcpy(&data[offset], §ion[12], size); |
|
| 134 |
+ std::copy_n(§ion[12], size, &data[offset]); |
|
| 135 | 135 |
} |
| 136 | 136 |
|
| 137 | 137 |
static bool MapGSF(XSFFile *xSF, int level) |
| ... | ... |
@@ -241,7 +241,7 @@ void XSFPlayer_GSF::GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, |
| 241 | 241 |
unsigned len = remainbytes; |
| 242 | 242 |
if (len > bytes) |
| 243 | 243 |
len = bytes; |
| 244 |
- memcpy(&buf[offset], &buffer.buf[buffer.cur], len); |
|
| 244 |
+ std::copy_n(&buffer.buf[buffer.cur], len, &buf[offset]); |
|
| 245 | 245 |
bytes -= len; |
| 246 | 246 |
offset += len; |
| 247 | 247 |
buffer.cur += len; |
| ... | ... |
@@ -13,13 +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), |
| 14 | 14 |
interpolation(INTERPOLATION_NONE) |
| 15 | 15 |
{
|
| 16 |
- memset(this->trackIds, 0, sizeof(this->trackIds)); |
|
| 16 |
+ std::fill_n(&this->trackIds[0], FSS_TRACKCOUNT, 0); |
|
| 17 | 17 |
for (int8_t i = 0; i < 16; ++i) |
| 18 | 18 |
{
|
| 19 | 19 |
this->channels[i].chnId = i; |
| 20 | 20 |
this->channels[i].ply = this; |
| 21 | 21 |
} |
| 22 |
- memset(this->variables, -1, sizeof(this->variables)); |
|
| 22 |
+ std::fill_n(&this->variables[0], 32, -1); |
|
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 | 25 |
// Original FSS Function: Player_Setup |
| ... | ... |
@@ -49,7 +49,7 @@ void Player::ClearState() |
| 49 | 49 |
this->tempoCount = 0; |
| 50 | 50 |
this->tempoRate = 0x100; |
| 51 | 51 |
this->masterVol = 0; // this is actually the highest level |
| 52 |
- memset(this->variables, -1, sizeof(this->variables)); |
|
| 52 |
+ std::fill_n(&this->variables[0], 32, -1); |
|
| 53 | 53 |
} |
| 54 | 54 |
|
| 55 | 55 |
// Original FSS Function: Player_FreeTracks |
| ... | ... |
@@ -81,7 +81,7 @@ void SBNKInstrument::Read(PseudoFile &file, uint32_t startOffset) |
| 81 | 81 |
|
| 82 | 82 |
SBNK::SBNK(const std::string &fn) : filename(fn), instruments(), info() |
| 83 | 83 |
{
|
| 84 |
- memset(this->waveArc, 0, sizeof(this->waveArc)); |
|
| 84 |
+ std::fill_n(&this->waveArc[0], 4, nullptr); |
|
| 85 | 85 |
} |
| 86 | 86 |
|
| 87 | 87 |
void SBNK::Read(PseudoFile &file) |
| ... | ... |
@@ -38,7 +38,7 @@ void Track::Zero() |
| 38 | 38 |
this->startPos = this->pos = nullptr; |
| 39 | 39 |
std::fill_n(&this->stack[0], FSS_TRACKSTACKSIZE, StackValue()); |
| 40 | 40 |
this->stackPos = 0; |
| 41 |
- memset(this->loopCount, 0, sizeof(this->loopCount)); |
|
| 41 |
+ std::fill_n(&this->loopCount[0], FSS_TRACKSTACKSIZE, 0); |
|
| 42 | 42 |
this->overriding() = false; |
| 43 | 43 |
this->lastComparisonResult = true; |
| 44 | 44 |
|
| ... | ... |
@@ -43,7 +43,7 @@ struct PseudoFile |
| 43 | 43 |
|
| 44 | 44 |
template<size_t N> void ReadLE(uint8_t arr[N]) |
| 45 | 45 |
{
|
| 46 |
- memcpy(&arr[0], &(*this->data)[this->pos], N); |
|
| 46 |
+ std::copy_n(&(*this->data)[this->pos], N, &arr[0]); |
|
| 47 | 47 |
this->pos += N; |
| 48 | 48 |
} |
| 49 | 49 |
|
| ... | ... |
@@ -55,7 +55,7 @@ struct PseudoFile |
| 55 | 55 |
|
| 56 | 56 |
void ReadLE(std::vector<uint8_t> &arr) |
| 57 | 57 |
{
|
| 58 |
- memcpy(&arr[0], &(*this->data)[this->pos], arr.size()); |
|
| 58 |
+ std::copy_n(&(*this->data)[this->pos], arr.size(), &arr[0]); |
|
| 59 | 59 |
this->pos += arr.size(); |
| 60 | 60 |
} |
| 61 | 61 |
|
| ... | ... |
@@ -43,7 +43,7 @@ void XSFPlayer_NCSF::MapNCSFSection(const std::vector<uint8_t> §ion) |
| 43 | 43 |
this->sdatData.resize(finalSize, 0); |
| 44 | 44 |
else if (this->sdatData.size() < size) |
| 45 | 45 |
this->sdatData.resize(finalSize); |
| 46 |
- memcpy(&this->sdatData[0], §ion[0], size); |
|
| 46 |
+ std::copy_n(§ion[0], size, &this->sdatData[0]); |
|
| 47 | 47 |
} |
| 48 | 48 |
|
| 49 | 49 |
bool XSFPlayer_NCSF::MapNCSF(XSFFile *xSFToLoad) |
| ... | ... |
@@ -134,7 +134,7 @@ std::vector<uint8_t> DialogTemplate::DialogGroup::GenerateControlTemplate() cons |
| 134 | 134 |
*reinterpret_cast<uint16_t *>(&data[16]) = static_cast<uint16_t>(this->id); |
| 135 | 135 |
*reinterpret_cast<uint16_t *>(&data[18]) = 0xFFFF; |
| 136 | 136 |
*reinterpret_cast<uint16_t *>(&data[20]) = 0x0080; |
| 137 |
- memcpy(reinterpret_cast<wchar_t *>(&data[22]), this->groupName.c_str(), this->groupName.length() * sizeof(wchar_t)); |
|
| 137 |
+ std::copy_n(this->groupName.c_str(), this->groupName.length(), reinterpret_cast<wchar_t *>(&data[22])); |
|
| 138 | 138 |
|
| 139 | 139 |
std::for_each(this->controls.begin(), this->controls.end(), [&](const std::unique_ptr<DialogControl> &control) |
| 140 | 140 |
{
|
| ... | ... |
@@ -175,7 +175,7 @@ std::vector<uint8_t> DialogTemplate::DialogControlWithLabel::GenerateControlTemp |
| 175 | 175 |
*reinterpret_cast<uint16_t *>(&data[16]) = static_cast<uint16_t>(this->id); |
| 176 | 176 |
*reinterpret_cast<uint16_t *>(&data[18]) = 0xFFFF; |
| 177 | 177 |
*reinterpret_cast<uint16_t *>(&data[20]) = this->type; |
| 178 |
- memcpy(reinterpret_cast<wchar_t *>(&data[22]), this->label.c_str(), this->label.length() * sizeof(wchar_t)); |
|
| 178 |
+ std::copy_n(this->label.c_str(), this->label.length(), reinterpret_cast<wchar_t *>(&data[22])); |
|
| 179 | 179 |
|
| 180 | 180 |
return data; |
| 181 | 181 |
} |
| ... | ... |
@@ -346,11 +346,11 @@ const DLGTEMPLATE *DialogTemplate::GenerateTemplate() |
| 346 | 346 |
*reinterpret_cast<uint16_t *>(&this->templateData[8]) = controlCount; |
| 347 | 347 |
*reinterpret_cast<uint16_t *>(&this->templateData[14]) = this->size.width; |
| 348 | 348 |
*reinterpret_cast<uint16_t *>(&this->templateData[16]) = this->size.height; |
| 349 |
- memcpy(reinterpret_cast<wchar_t *>(&this->templateData[22]), this->title.c_str(), this->title.length() * sizeof(wchar_t)); |
|
| 349 |
+ std::copy_n(this->title.c_str(), this->title.length(), reinterpret_cast<wchar_t *>(&this->templateData[22])); |
|
| 350 | 350 |
if (!this->fontName.empty()) |
| 351 | 351 |
{
|
| 352 | 352 |
*reinterpret_cast<uint16_t *>(&this->templateData[22 + sizeof(wchar_t) * (this->title.length() + 1)]) = this->fontSizeInPts; |
| 353 |
- 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)); |
|
| 353 |
+ std::copy_n(this->fontName.c_str(), this->fontName.length(), reinterpret_cast<wchar_t *>(&this->templateData[24 + sizeof(wchar_t) * (this->title.length() + 1)])); |
|
| 354 | 354 |
} |
| 355 | 355 |
|
| 356 | 356 |
std::for_each(this->controls.begin(), this->controls.end(), [&](const std::unique_ptr<DialogControl> &control) |
| ... | ... |
@@ -128,7 +128,7 @@ void XSFFile::ReadXSF(std::ifstream &xSF, uint32_t programSizeOffset, uint32_t p |
| 128 | 128 |
this->xSFType = PSFHeader[3]; |
| 129 | 129 |
|
| 130 | 130 |
this->rawData.resize(4); |
| 131 |
- memcpy(&this->rawData[0], PSFHeader, 4); |
|
| 131 |
+ std::copy_n(PSFHeader, 4, &this->rawData[0]); |
|
| 132 | 132 |
|
| 133 | 133 |
if (filesize < 16) |
| 134 | 134 |
throw std::runtime_error("File is too small.");
|
| ... | ... |
@@ -150,7 +150,7 @@ void XSFFile::ReadXSF(std::ifstream &xSF, uint32_t programSizeOffset, uint32_t p |
| 150 | 150 |
{
|
| 151 | 151 |
this->reservedSection.resize(reservedSize); |
| 152 | 152 |
xSF.read(reinterpret_cast<char *>(&this->reservedSection[0]), reservedSize); |
| 153 |
- memcpy(&this->rawData[16], &this->reservedSection[0], reservedSize); |
|
| 153 |
+ std::copy_n(&this->reservedSection[0], reservedSize, &this->rawData[16]); |
|
| 154 | 154 |
} |
| 155 | 155 |
} |
| 156 | 156 |
|
| ... | ... |
@@ -165,7 +165,7 @@ void XSFFile::ReadXSF(std::ifstream &xSF, uint32_t programSizeOffset, uint32_t p |
| 165 | 165 |
{
|
| 166 | 166 |
auto programSectionCompressed = std::vector<uint8_t>(programCompressedSize); |
| 167 | 167 |
xSF.read(reinterpret_cast<char *>(&programSectionCompressed[0]), programCompressedSize); |
| 168 |
- memcpy(&this->rawData[reservedSize + 16], &programSectionCompressed[0], programCompressedSize); |
|
| 168 |
+ std::copy_n(&programSectionCompressed[0], programCompressedSize, &this->rawData[reservedSize + 16]); |
|
| 169 | 169 |
|
| 170 | 170 |
auto programSectionUncompressed = std::vector<uint8_t>(programHeaderSize); |
| 171 | 171 |
unsigned long programUncompressedSize = programHeaderSize; |
| ... | ... |
@@ -488,7 +488,7 @@ extern "C" __declspec(dllexport) size_t winampGetExtendedRead_getData(intptr_t h |
| 488 | 488 |
auto sampleBuffer = std::vector<uint8_t>(576 * NumChannels * (BitsPerSample / 8)); |
| 489 | 489 |
unsigned samplesWritten = 0; |
| 490 | 490 |
done = tmpxSFPlayer->FillBuffer(sampleBuffer, samplesWritten); |
| 491 |
- memcpy(&dest[copied], &sampleBuffer[0], samplesWritten * NumChannels * (BitsPerSample / 8)); |
|
| 491 |
+ std::copy_n(&sampleBuffer[0], samplesWritten * NumChannels * (BitsPerSample / 8), &dest[copied]); |
|
| 492 | 492 |
copied += samplesWritten * NumChannels * (BitsPerSample / 8); |
| 493 | 493 |
if (killswitch && *killswitch) |
| 494 | 494 |
break; |