Asterisk - The Open Source Telephony Project  18.5.0
Functions
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

◆ __bt_get()

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, errno, F_ISSET, __db::internal, mpool_put(), NULL, _epg::page, RET_ERROR, RET_SPECIAL, and status.

Referenced by __bt_open().

68 {
69  BTREE *t;
70  EPG *e;
71  int exact, status;
72 
73  t = dbp->internal;
74 
75  /* Toss any page pinned across calls. */
76  if (t->bt_pinned != NULL) {
77  mpool_put(t->bt_mp, t->bt_pinned, 0);
78  t->bt_pinned = NULL;
79  }
80 
81  /* Get currently doesn't take any flags. */
82  if (flags) {
83  errno = EINVAL;
84  return (RET_ERROR);
85  }
86 
87  if ((e = __bt_search(t, key, &exact)) == NULL)
88  return (RET_ERROR);
89  if (!exact) {
90  mpool_put(t->bt_mp, e->page, 0);
91  return (RET_SPECIAL);
92  }
93 
94  status = __bt_ret(t, e, NULL, NULL, data, &t->bt_rdata, 0);
95 
96  /*
97  * If the user is doing concurrent access, we copied the
98  * key/data, toss the page.
99  */
100  if (F_ISSET(t, B_DB_LOCK))
101  mpool_put(t->bt_mp, e->page, 0);
102  else
103  t->bt_pinned = e->page;
104  return (status);
105 }
#define RET_ERROR
Definition: db.h:51
#define F_ISSET(p, f)
Definition: btree.h:42
int mpool_put(MPOOL *mp, void *page, u_int flags)
Definition: mpool.c:251
Definition: btree.h:254
void * internal
Definition: db.h:137
#define NULL
Definition: resample.c:96
Definition: btree.h:312
int __bt_ret(BTREE *t, EPG *e, DBT *key, DBT *rkey, DBT *data, DBT *rdata, int copy)
Definition: bt_utils.c:67
PAGE * bt_pinned
Definition: btree.h:318
DBT bt_rdata
Definition: btree.h:333
PAGE * page
Definition: btree.h:255
MPOOL * bt_mp
Definition: btree.h:313
int errno
EPG * __bt_search(BTREE *t, const DBT *key, int *exactp)
Definition: bt_search.c:66
#define RET_SPECIAL
Definition: db.h:53
#define B_DB_LOCK
Definition: btree.h:385
jack_status_t status
Definition: app_jack.c:146