was returning a pointer into the stack!
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 17 Sep 1993 07:41:42 +0000 (23:41 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 17 Sep 1993 07:41:42 +0000 (23:41 -0800)
change to use bt_cur as bt_search does

SCCS-vsn: lib/libc/db/btree/bt_put.c 8.3

usr/src/lib/libc/db/btree/bt_put.c

index 817f9a2..e607ee6 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_put.c   8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)bt_put.c   8.3 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -240,7 +240,6 @@ bt_fast(t, key, data, exactp)
        const DBT *key, *data;
        int *exactp;
 {
        const DBT *key, *data;
        int *exactp;
 {
-       EPG e;
        PAGE *h;
        size_t nbytes;
        int cmp;
        PAGE *h;
        size_t nbytes;
        int cmp;
@@ -249,8 +248,8 @@ bt_fast(t, key, data, exactp)
                t->bt_order = NOT;
                return (NULL);
        }
                t->bt_order = NOT;
                return (NULL);
        }
-       e.page = h;
-       e.index = t->bt_last.index;
+       t->bt_cur.page = h;
+       t->bt_cur.index = t->bt_last.index;
 
        /*
         * If won't fit in this page or have too many keys in this page, have
 
        /*
         * If won't fit in this page or have too many keys in this page, have
@@ -261,19 +260,19 @@ bt_fast(t, key, data, exactp)
                goto miss;
 
        if (t->bt_order == FORWARD) {
                goto miss;
 
        if (t->bt_order == FORWARD) {
-               if (e.page->nextpg != P_INVALID)
+               if (t->bt_cur.page->nextpg != P_INVALID)
                        goto miss;
                        goto miss;
-               if (e.index != NEXTINDEX(h) - 1)
+               if (t->bt_cur.index != NEXTINDEX(h) - 1)
                        goto miss;
                        goto miss;
-               if ((cmp = __bt_cmp(t, key, &e)) < 0)
+               if ((cmp = __bt_cmp(t, key, &t->bt_cur)) < 0)
                        goto miss;
                        goto miss;
-               t->bt_last.index = cmp ? ++e.index : e.index;
+               t->bt_last.index = cmp ? ++t->bt_cur.index : t->bt_cur.index;
        } else {
        } else {
-               if (e.page->prevpg != P_INVALID)
+               if (t->bt_cur.page->prevpg != P_INVALID)
                        goto miss;
                        goto miss;
-               if (e.index != 0)
+               if (t->bt_cur.index != 0)
                        goto miss;
                        goto miss;
-               if ((cmp = __bt_cmp(t, key, &e)) > 0)
+               if ((cmp = __bt_cmp(t, key, &t->bt_cur)) > 0)
                        goto miss;
                t->bt_last.index = 0;
        }
                        goto miss;
                t->bt_last.index = 0;
        }
@@ -281,7 +280,7 @@ bt_fast(t, key, data, exactp)
 #ifdef STATISTICS
        ++bt_cache_hit;
 #endif
 #ifdef STATISTICS
        ++bt_cache_hit;
 #endif
-       return (&e);
+       return (&t->bt_cur);
 
 miss:
 #ifdef STATISTICS
 
 miss:
 #ifdef STATISTICS