mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2024-11-22 13:55:38 +00:00
Byte swapping utility function
This commit is contained in:
parent
718c237063
commit
037bfc648d
14
Src/Util/ByteSwap.cpp
Normal file
14
Src/Util/ByteSwap.cpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include "Util/ByteSwap.h"
|
||||
|
||||
namespace Util
|
||||
{
|
||||
void ByteSwap(uint8_t *buffer, size_t size)
|
||||
{
|
||||
for (size_t i = 0; i < (size & ~1); i += 2)
|
||||
{
|
||||
uint8_t x = buffer[i + 0];
|
||||
buffer[i + 0] = buffer[i + 1];
|
||||
buffer[i + 1] = x;
|
||||
}
|
||||
}
|
||||
} // Util
|
12
Src/Util/ByteSwap.h
Normal file
12
Src/Util/ByteSwap.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef INCLUDED_BYTESWAP_H
|
||||
#define INCLUDED_BYTESWAP_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace Util
|
||||
{
|
||||
void ByteSwap(uint8_t *buffer, size_t size);
|
||||
} // Util
|
||||
|
||||
#endif // INCLUDED_BYTESWAP_H
|
Loading…
Reference in a new issue