]> git.saurik.com Git - apple/libc.git/blobdiff - db/recno/FreeBSD/rec_search.c
Libc-763.11.tar.gz
[apple/libc.git] / db / recno / FreeBSD / rec_search.c
index 3353bfb380205eaa53a417bd8774e1eb01b1018a..545209f2169ff42a37ea7d4fdd4af409e064c1ab 100644 (file)
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
  * 4. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
@@ -35,7 +31,7 @@
 static char sccsid[] = "@(#)rec_search.c       8.4 (Berkeley) 7/14/94";
 #endif /* LIBC_SCCS and not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/db/recno/rec_search.c,v 1.4 2002/03/21 18:47:38 obrien Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/db/recno/rec_search.c,v 1.8 2009/03/04 00:58:04 delphij Exp $");
 
 #include <sys/types.h>
 
@@ -51,7 +47,7 @@ __FBSDID("$FreeBSD: src/lib/libc/db/recno/rec_search.c,v 1.4 2002/03/21 18:47:38
  * Parameters:
  *     t:      tree to search
  *     recno:  key to find
- *     op:     search operation
+ *     op:     search operation
  *
  * Returns:
  *     EPG for matching record, if any, or the EPG for the location of the
@@ -63,12 +59,9 @@ __FBSDID("$FreeBSD: src/lib/libc/db/recno/rec_search.c,v 1.4 2002/03/21 18:47:38
  *     the bt_cur field of the tree.  A pointer to the field is returned.
  */
 EPG *
-__rec_search(t, recno, op)
-       BTREE *t;
-       recno_t recno;
-       enum SRCHOP op;
+__rec_search(BTREE *t, recno_t recno, enum SRCHOP op)
 {
-       indx_t index;
+       indx_t idx;
        PAGE *h;
        EPGNO *parent;
        RINTERNAL *r;
@@ -86,23 +79,23 @@ __rec_search(t, recno, op)
                        t->bt_cur.index = recno - total;
                        return (&t->bt_cur);
                }
-               for (index = 0, top = NEXTINDEX(h);;) {
-                       r = GETRINTERNAL(h, index);
-                       if (++index == top || total + r->nrecs > recno)
+               for (idx = 0, top = NEXTINDEX(h);;) {
+                       r = GETRINTERNAL(h, idx);
+                       if (++idx == top || total + r->nrecs > recno)
                                break;
                        total += r->nrecs;
                }
 
-               BT_PUSH(t, pg, index - 1);
-               
+               BT_PUSH(t, pg, idx - 1);
+
                pg = r->pgno;
                switch (op) {
                case SDELETE:
-                       --GETRINTERNAL(h, (index - 1))->nrecs;
+                       --GETRINTERNAL(h, (idx - 1))->nrecs;
                        mpool_put(t->bt_mp, h, MPOOL_DIRTY);
                        break;
                case SINSERT:
-                       ++GETRINTERNAL(h, (index - 1))->nrecs;
+                       ++GETRINTERNAL(h, (idx - 1))->nrecs;
                        mpool_put(t->bt_mp, h, MPOOL_DIRTY);
                        break;
                case SEARCH:
@@ -121,8 +114,8 @@ err:        sverrno = errno;
                                --GETRINTERNAL(h, parent->index)->nrecs;
                        else
                                ++GETRINTERNAL(h, parent->index)->nrecs;
-                        mpool_put(t->bt_mp, h, MPOOL_DIRTY);
-                }
+                       mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+               }
        errno = sverrno;
        return (NULL);
 }