Cube/src/tools.m
Jonathan Schleifer 3a7e871e0e Remove u{char,short,int}
FossilOrigin-Name: b5bfe2af86efc76d1ac600bf7cda4a1709aaa95ae2392ee9e3f98ce6d4b14bcf
2025-03-23 02:59:37 +00:00

22 lines
479 B
Objective-C

// implementation of generic tools
#include "tools.h"
///////////////////////// misc tools ///////////////////////
void
endianswap(
void *memory, int stride, int length) // little indians as storage format
{
if (*((char *)&stride))
return;
for (int w = 0; w < length; w++) {
for (int i = 0; i < stride / 2; i++) {
unsigned char *p = (unsigned char *)memory + w * stride;
unsigned char t = p[i];
p[i] = p[stride - i - 1];
p[stride - i - 1] = t;
}
}
}