Util: RingFIFO should be able to advance without memcpy

This commit is contained in:
Jeffrey Pfau 2016-08-06 22:05:46 -07:00
parent 4a1fc1caf8
commit 067d4c5836
1 changed files with 6 additions and 2 deletions

View File

@ -43,7 +43,9 @@ size_t RingFIFOWrite(struct RingFIFO* buffer, const void* value, size_t length)
if (remaining <= length) {
return 0;
}
if (value) {
memcpy(data, value, length);
}
buffer->writePtr = (void*) ((intptr_t) data + length);
return length;
}
@ -63,7 +65,9 @@ size_t RingFIFORead(struct RingFIFO* buffer, void* output, size_t length) {
if (remaining <= length) {
return 0;
}
if (output) {
memcpy(output, data, length);
}
buffer->readPtr = (void*) ((intptr_t) data + length);
return length;
}