Skip to content

Instantly share code, notes, and snippets.

@loopj
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loopj/47c1f52dfc49435a8e12 to your computer and use it in GitHub Desktop.
Save loopj/47c1f52dfc49435a8e12 to your computer and use it in GitHub Desktop.
// Works
class Something {
public:
void doSomething() {
uint8_t buffer[1024];
memcpy(buffer + bufferPosition, something);
bufferPosition += someSize;
memcpy(buffer + bufferPosition, something);
bufferPosition += someSize;
bufferPosition = 0;
}
private:
uint8_t bufferPosition = 0;
}
// Doesn't work
class Something {
public:
void doSomething() {
memcpy(buffer + bufferPosition, something);
bufferPosition += someSize;
memcpy(buffer + bufferPosition, something);
bufferPosition += someSize;
bufferPosition = 0;
}
private:
uint8_t buffer[1024];
uint8_t bufferPosition = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment