/[resiprocate]/main/contrib/db/btree/bt_reclaim.c
ViewVC logotype

Contents of /main/contrib/db/btree/bt_reclaim.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5295 - (show annotations) (download)
Mon Aug 22 00:30:05 2005 UTC (14 years, 2 months ago) by jason
File MIME type: text/plain
File size: 1334 byte(s)
merged 5270:HEAD from b-directory-reorg
1 /*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 1998-2004
5 * Sleepycat Software. All rights reserved.
6 *
7 * $Id: bt_reclaim.c,v 11.15 2004/01/28 03:35:49 bostic Exp $
8 */
9
10 #include "db_config.h"
11
12 #ifndef NO_SYSTEM_INCLUDES
13 #include <sys/types.h>
14
15 #include <string.h>
16 #endif
17
18 #include "db_int.h"
19 #include "dbinc/db_page.h"
20 #include "dbinc/btree.h"
21
22 /*
23 * __bam_reclaim --
24 * Free a database.
25 *
26 * PUBLIC: int __bam_reclaim __P((DB *, DB_TXN *));
27 */
28 int
29 __bam_reclaim(dbp, txn)
30 DB *dbp;
31 DB_TXN *txn;
32 {
33 DBC *dbc;
34 int ret, t_ret;
35
36 /* Acquire a cursor. */
37 if ((ret = __db_cursor(dbp, txn, &dbc, 0)) != 0)
38 return (ret);
39
40 /* Walk the tree, freeing pages. */
41 ret = __bam_traverse(dbc,
42 DB_LOCK_WRITE, dbc->internal->root, __db_reclaim_callback, dbc);
43
44 /* Discard the cursor. */
45 if ((t_ret = __db_c_close(dbc)) != 0 && ret == 0)
46 ret = t_ret;
47
48 return (ret);
49 }
50
51 /*
52 * __bam_truncate --
53 * Truncate a database.
54 *
55 * PUBLIC: int __bam_truncate __P((DBC *, u_int32_t *));
56 */
57 int
58 __bam_truncate(dbc, countp)
59 DBC *dbc;
60 u_int32_t *countp;
61 {
62 db_trunc_param trunc;
63 int ret;
64
65 trunc.count = 0;
66 trunc.dbc = dbc;
67
68 /* Walk the tree, freeing pages. */
69 ret = __bam_traverse(dbc,
70 DB_LOCK_WRITE, dbc->internal->root, __db_truncate_callback, &trunc);
71
72 *countp = trunc.count;
73
74 return (ret);
75 }

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27