Skip to content

Conversation

@socram8888
Copy link
Contributor

Current code is causing compilation errors in Debian bookworm. Replacing std::memcpy with just memcpy (as the rest of the memcpy calls are) fixed the issue.

builder.cc: In function ‘void createImage(ImageSettings, const uint8_t*, uint32_t)’:
builder.cc:693:14: error: ‘memcpy’ is not a member of ‘std’; did you mean ‘wmemcpy’?
  693 |         std::memcpy(out.data() + out.size() / 2, out.data(), out.size() / 2);
      |              ^~~~~~
      |              wmemcpy

@alex-free
Copy link

Duplicate of #97

@alex-free
Copy link

alex-free commented Nov 24, 2022

Actually I don't know what's better. I initially did the same thing for my pull request but then realized I could just add #include cstring to fix it and settled on that.

@socram8888
Copy link
Contributor Author

Not sure. There's only one std::memcpy and plenty of regular memcpy in that file, so I guessed this one was a mistake.

// This cheap fix makes it possible to use fake memory cards with a 512 kbits (64 kB) chip.
if (payloadOffset + payload.size() <= out.size() / 2) {
std::memcpy(out.data() + out.size() / 2, out.data(), out.size() / 2);
memcpy(out.data() + out.size() / 2, out.data(), out.size() / 2);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe:
const size_t half_size = out.size() >> 1;
memcpy(out.data() + half_size, out.data(), half_size);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants