1 /* mfree.c - memory-mapped database freelist scanner */
3 * Copyright 2011 Howard Chu, Symas Corp.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted only as authorized by the OpenLDAP
10 * A copy of this license is available in the file LICENSE in the
11 * top-level directory of the distribution or, alternatively, at
12 * <http://www.OpenLDAP.org/license.html>.
14 #define _XOPEN_SOURCE 500 /* srandom(), random() */
21 int main(int argc,char * argv[])
33 fprintf(stderr, "usage: %s <pathname>\n", argv[0]);
37 rc = mdb_env_create(&env);
38 rc = mdb_env_open(env, argv[1], MDB_RDONLY, 0664);
39 rc = mdb_txn_begin(env, NULL, MDB_RDONLY, &txn);
41 rc = mdb_cursor_open(txn, dbi, &cursor);
42 while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) {
43 printf("key: %p %zu, data: %p\n",
44 key.mv_data, *(ID *) key.mv_data,
49 printf(" %zu\n", iptr[i]);
51 mdb_cursor_close(cursor);