mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 02:27:26 -07:00
moved and unified some reverse array fct
This commit is contained in:
parent
32a06758bb
commit
7abfff4095
5 changed files with 51 additions and 38 deletions
|
@ -269,3 +269,27 @@ uint16_t get_sw(const uint8_t *d, uint16_t n) {
|
|||
n -= 2;
|
||||
return (d[n] << 8 | d[n + 1]);
|
||||
}
|
||||
|
||||
// reverse same array
|
||||
void reverse_array(uint8_t *d, size_t n) {
|
||||
if (d == NULL || n < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0, j = n - 1; i < j; ++i, --j) {
|
||||
d[i] ^= d[j];
|
||||
d[j] ^= d[i];
|
||||
d[i] ^= d[j];
|
||||
}
|
||||
}
|
||||
|
||||
// reverse src array into dest array
|
||||
void reverse_array_copy(const uint8_t *src, int src_len, uint8_t *dest) {
|
||||
if (src == NULL || src_len == 0 || dest == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < src_len; i++) {
|
||||
dest[i] = src[(src_len - 1) - i];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue