Asterisk - The Open Source Telephony Project  18.5.0
Functions
bt_page.c File Reference
#include <sys/types.h>
#include <stdio.h>
#include "../include/db.h"
#include "btree.h"
Include dependency graph for bt_page.c:

Go to the source code of this file.

Functions

int __bt_free (BTREE *t, PAGE *h)
 
PAGE__bt_new (BTREE *t, pgno_t *npg)
 

Function Documentation

◆ __bt_free()

int __bt_free ( BTREE t,
PAGE h 
)

Definition at line 60 of file bt_page.c.

References B_METADIRTY, _btree::bt_free, _btree::bt_mp, F_SET, MPOOL_DIRTY, mpool_put(), _page::nextpg, P_INVALID, _page::pgno, and _page::prevpg.

Referenced by __bt_pdelete(), and __ovfl_delete().

63 {
64  /* Insert the page at the head of the free list. */
65  h->prevpg = P_INVALID;
66  h->nextpg = t->bt_free;
67  t->bt_free = h->pgno;
68  F_SET(t, B_METADIRTY);
69 
70  /* Make sure the page gets written back. */
71  return (mpool_put(t->bt_mp, h, MPOOL_DIRTY));
72 }
pgno_t pgno
Definition: btree.h:76
#define F_SET(p, f)
Definition: btree.h:40
int mpool_put(MPOOL *mp, void *page, u_int flags)
Definition: mpool.c:251
#define MPOOL_DIRTY
Definition: mpool.h:61
MPOOL * bt_mp
Definition: btree.h:313
pgno_t nextpg
Definition: btree.h:78
pgno_t prevpg
Definition: btree.h:77
#define B_METADIRTY
Definition: btree.h:369
#define P_INVALID
Definition: btree.h:63
pgno_t bt_free
Definition: btree.h:337

◆ __bt_new()

PAGE* __bt_new ( BTREE t,
pgno_t npg 
)

Definition at line 86 of file bt_page.c.

References B_METADIRTY, _btree::bt_free, _btree::bt_mp, F_SET, mpool_get(), mpool_new(), _page::nextpg, NULL, and P_INVALID.

Referenced by __ovfl_put(), bt_page(), and bt_root().

89 {
90  PAGE *h;
91 
92  if (t->bt_free != P_INVALID &&
93  (h = mpool_get(t->bt_mp, t->bt_free, 0)) != NULL) {
94  *npg = t->bt_free;
95  t->bt_free = h->nextpg;
96  F_SET(t, B_METADIRTY);
97  return (h);
98  }
99  return (mpool_new(t->bt_mp, npg));
100 }
Definition: btree.h:75
#define F_SET(p, f)
Definition: btree.h:40
#define NULL
Definition: resample.c:96
void * mpool_get(MPOOL *mp, pgno_t pgno, u_int flags)
Definition: mpool.c:165
MPOOL * bt_mp
Definition: btree.h:313
pgno_t nextpg
Definition: btree.h:78
#define B_METADIRTY
Definition: btree.h:369
#define P_INVALID
Definition: btree.h:63
void * mpool_new(MPOOL *mp, pgno_t *pgnoaddr)
Definition: mpool.c:130
pgno_t bt_free
Definition: btree.h:337