]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - util.c
AUTHORS
[xonotic/gmqcc.git] / util.c
diff --git a/util.c b/util.c
index 62f6e149ec04db07a27ea5a2f8f2866b9d58664b..010de9704da460444ab8030e9220dbe2ce0b4e91 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;
         }
     }
 }
@@ -242,7 +244,7 @@ int util_getline(char **lineptr, size_t *n, FILE *stream) {
     if (!lineptr || !n || !stream)
         return -1;
     if (!*lineptr) {
-        if (!(*lineptr = mem_a((*n = 64))))
+        if (!(*lineptr = mem_a((*n=64))))
             return -1;
     }