]> git.sur5r.net Git - cc65/blobdiff - libsrc/common/bsearch.c
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / common / bsearch.c
index 47cbc4e1c010cdcb53f91fc3e584687bd8d4a46f..7d64dbbe9f5a0753317a22b124023b9cac8d31db 100644 (file)
 
 
 
-void* bsearch (void* key, void* base, size_t n, size_t size, int (*cmp) (void*, void*))
+void* __fastcall__ bsearch (const void* key, const void* base, size_t n,
+                            size_t size, int (*cmp) (const void*, const void*))
 {
-    int current;               
+    int current;
     int result;
     int found = 0;
     int first = 0;
@@ -21,23 +22,23 @@ void* bsearch (void* key, void* base, size_t n, size_t size, int (*cmp) (void*,
     /* Binary search */
     while (first <= last) {
 
-       /* Set current to mid of range */
-       current = (last + first) / 2;
+        /* Set current to mid of range */
+        current = (last + first) / 2;
 
-       /* Do a compare */
-               result = cmp ((void*) (((int) base) + current*size), key);
+        /* Do a compare */
+        result = cmp ((void*) (((int) base) + current*size), key);
         if (result < 0) {
-           first = current + 1;
-       } else {
-           last = current - 1;
-           if (result == 0) {
-               /* Found one entry that matches the search key. However there may be
-                * more than one entry with the same key value and ANSI guarantees
-                * that we return the first of a row of items with the same key.
-                */
-               found = 1;
-           }
-       }
+            first = current + 1;
+        } else {
+            last = current - 1;
+            if (result == 0) {
+                /* Found one entry that matches the search key. However there may be
+                 * more than one entry with the same key value and ANSI guarantees
+                 * that we return the first of a row of items with the same key.
+                 */
+                found = 1;
+            }
+        }
     }
 
     /* Did we find the entry? */