bt_get.c File Reference

#include <sys/types.h>
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include "../include/db.h"
#include "btree.h"

Include dependency graph for bt_get.c:

Go to the source code of this file.

Functions

int __bt_get (DB *dbp, const DBT *key, DBT *data, u_int flags) const


Function Documentation

int __bt_get ( DB dbp,
const DBT key,
DBT data,
u_int  flags 
) const

Definition at line 63 of file bt_get.c.

References __bt_ret(), __bt_search(), B_DB_LOCK, _btree::bt_mp, _btree::bt_pinned, _btree::bt_rdata, e, errno, F_ISSET, mpool_put, NULL, _epg::page, RET_ERROR, RET_SPECIAL, and status.

Referenced by __bt_open().

00068 {
00069    BTREE *t;
00070    EPG *e;
00071    int exact, status;
00072 
00073    t = dbp->internal;
00074 
00075    /* Toss any page pinned across calls. */
00076    if (t->bt_pinned != NULL) {
00077       mpool_put(t->bt_mp, t->bt_pinned, 0);
00078       t->bt_pinned = NULL;
00079    }
00080 
00081    /* Get currently doesn't take any flags. */
00082    if (flags) {
00083       errno = EINVAL;
00084       return (RET_ERROR);
00085    }
00086 
00087    if ((e = __bt_search(t, key, &exact)) == NULL)
00088       return (RET_ERROR);
00089    if (!exact) {
00090       mpool_put(t->bt_mp, e->page, 0);
00091       return (RET_SPECIAL);
00092    }
00093 
00094    status = __bt_ret(t, e, NULL, NULL, data, &t->bt_rdata, 0);
00095 
00096    /*
00097     * If the user is doing concurrent access, we copied the
00098     * key/data, toss the page.
00099     */
00100    if (F_ISSET(t, B_DB_LOCK))
00101       mpool_put(t->bt_mp, e->page, 0);
00102    else
00103       t->bt_pinned = e->page;
00104    return (status);
00105 }


Generated on Thu Apr 16 06:29:15 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6