summaryrefslogtreecommitdiffstats
path: root/debian/htdig/htdig-3.2.0b6/db/bt_reclaim.c
blob: ff44424a37e4994d55506c553382fe903db16dfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 1998, 1999
 *	Sleepycat Software.  All rights reserved.
 */

#include "db_config.h"

#ifndef lint
static const char sccsid[] = "@(#)bt_reclaim.c	11.1 (Sleepycat) 7/24/99";
#endif /* not lint */

#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>

#include <string.h>
#endif

#include "db_int.h"
#include "db_page.h"
#include "db_shash.h"
#include "lock.h"
#include "btree.h"

/*
 * CDB___bam_reclaim --
 *	Free a database.
 *
 * PUBLIC: int CDB___bam_reclaim __P((DB *, DB_TXN *));
 */
int
CDB___bam_reclaim(dbp, txn)
	DB *dbp;
	DB_TXN *txn;
{
	BTREE *t;
	DBC *dbc;
	int ret, t_ret;

	/* Acquire a cursor. */
	if ((ret = dbp->cursor(dbp, txn, &dbc, 0)) != 0)
		return (ret);

	/* Walk the tree, freeing pages. */
	t = dbp->bt_internal;
	ret = CDB___bam_traverse(dbc,
	    DB_LOCK_WRITE, t->bt_root, CDB___db_reclaim_callback, dbc);

	/* Discard the cursor. */
	if ((t_ret = dbc->c_close(dbc)) != 0 && ret == 0)
		ret = t_ret;

	return (ret);
}