archivers/wad.c
branchstable-1.0
changeset 927 8867d6c60ebf
parent 698 227bdc7957ca
--- a/archivers/wad.c	Wed Feb 13 05:48:57 2008 +0000
+++ b/archivers/wad.c	Wed Feb 20 12:24:10 2008 +0000
@@ -287,19 +287,27 @@
 
 static int wad_entry_cmp(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two)
 {
-    WADentry *a = (WADentry *) _a;
-    return(strcmp(a[one].name, a[two].name));
+    if (one != two)
+    {
+        const WADentry *a = (const WADentry *) _a;
+        return(strcmp(a[one].name, a[two].name));
+    } /* if */
+
+    return 0;
 } /* wad_entry_cmp */
 
 
 static void wad_entry_swap(void *_a, PHYSFS_uint32 one, PHYSFS_uint32 two)
 {
-    WADentry tmp;
-    WADentry *first = &(((WADentry *) _a)[one]);
-    WADentry *second = &(((WADentry *) _a)[two]);
-    memcpy(&tmp, first, sizeof (WADentry));
-    memcpy(first, second, sizeof (WADentry));
-    memcpy(second, &tmp, sizeof (WADentry));
+    if (one != two)
+    {
+        WADentry tmp;
+        WADentry *first = &(((WADentry *) _a)[one]);
+        WADentry *second = &(((WADentry *) _a)[two]);
+        memcpy(&tmp, first, sizeof (WADentry));
+        memcpy(first, second, sizeof (WADentry));
+        memcpy(second, &tmp, sizeof (WADentry));
+    } /* if */
 } /* wad_entry_swap */