make procarr code more consise.

This commit is contained in:
2025-08-24 12:48:21 +02:00
parent 29c8a2b6ea
commit 7feb193c51

View File

@@ -110,20 +110,12 @@ MALLOC static void *nbt_procarr(const u8 *restrict buf, i32 nmem, uint size) {
ssize_t i = 0; ssize_t i = 0;
while (i < nmem) { while (i < nmem) {
switch (size) { switch (size) {
case 2: case 2: *(u16 *)(ptr + i) = be16toh(*(u16 *)(ptr + i)); break;
*(u16 *)(ptr + i) = be16toh(*(u16 *)(ptr + i)); case 4: *(u32 *)(ptr + i) = be32toh(*(u32 *)(ptr + i)); break;
i += 2; case 8: *(u64 *)(ptr + i) = be64toh(*(u64 *)(ptr + i)); break;
break;
case 4:
*(u32 *)(ptr + i) = be32toh(*(u32 *)(ptr + i));
i += 4;
break;
case 8:
*(u64 *)(ptr + i) = be64toh(*(u64 *)(ptr + i));
i += 8;
break;
default: __builtin_unreachable(); // this should be impossible default: __builtin_unreachable(); // this should be impossible
} }
i += size;
} }
#endif #endif
return ptr; return ptr;