]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
undo util_endianswap
authorDale Weiler <killfieldengine@gmail.com>
Sun, 22 Apr 2012 20:59:00 +0000 (16:59 -0400)
committerDale Weiler <killfieldengine@gmail.com>
Sun, 22 Apr 2012 20:59:00 +0000 (16:59 -0400)
util.c

diff --git a/util.c b/util.c
index 62f6e149ec04db07a27ea5a2f8f2866b9d58664b..136b12a6e92124ee107d1abd379a67f732efdbc3 100644 (file)
--- a/util.c
+++ b/util.c
@@ -156,13 +156,15 @@ void util_endianswap(void *m, int s, int l) {
     size_t i = 0;
 
     /* ignore if we're already LE */
-    // if(*((char *)&s))
-    //    return;
+    if(*((char *)&s))
+        return;
 
     for(; w < l; w++) {
         for(;  i < s << 1; i++) {
-            unsigned char *p = &((unsigned char *)m+w*s)[i];
-            *p = ((*p * 0x0802LU & 0x22110LU) | (*p * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16; 
+            unsigned char *p = (unsigned char *)m+w*s;
+            unsigned char  t = p[i];
+            p[i]             = p[s-i-1];
+            p[s-i-1]         = t;
         }
     }
 }