Deleted Added
full compact
2c2
< * Copyright (c) 1990, 1993
---
> * Copyright (c) 1990, 1993, 1994
38c38
< static char sccsid[] = "@(#)bt_close.c 8.3 (Berkeley) 2/21/94";
---
> static char sccsid[] = "@(#)bt_close.c 8.7 (Berkeley) 8/17/94";
78,84c78
< /*
< * Delete any already deleted record that we've been saving
< * because the cursor pointed to it.
< */
< if (ISSET(t, B_DELCRSR) && __bt_crsrdel(t, &t->bt_bcursor))
< return (RET_ERROR);
<
---
> /* Sync the tree. */
87a82
> /* Close the memory pool. */
91,96c86,101
< if (t->bt_stack)
< free(t->bt_stack);
< if (t->bt_kbuf)
< free(t->bt_kbuf);
< if (t->bt_dbuf)
< free(t->bt_dbuf);
---
> /* Free random memory. */
> if (t->bt_cursor.key.data != NULL) {
> free(t->bt_cursor.key.data);
> t->bt_cursor.key.size = 0;
> t->bt_cursor.key.data = NULL;
> }
> if (t->bt_rkey.data) {
> free(t->bt_rkey.data);
> t->bt_rkey.size = 0;
> t->bt_rkey.data = NULL;
> }
> if (t->bt_rdata.data) {
> free(t->bt_rdata.data);
> t->bt_rdata.size = 0;
> t->bt_rdata.data = NULL;
> }
120,121d124
< PAGE *h;
< void *p;
137c140
< if (ISSET(t, B_INMEM | B_RDONLY) || !ISSET(t, B_MODIFIED))
---
> if (F_ISSET(t, B_INMEM | B_RDONLY) || !F_ISSET(t, B_MODIFIED))
140c143
< if (ISSET(t, B_METADIRTY) && bt_meta(t) == RET_ERROR)
---
> if (F_ISSET(t, B_METADIRTY) && bt_meta(t) == RET_ERROR)
143,160d145
< /*
< * Nastiness. If the cursor has been marked for deletion, but not
< * actually deleted, we have to make a copy of the page, delete the
< * key/data item, sync the file, and then restore the original page
< * contents.
< */
< if (ISSET(t, B_DELCRSR)) {
< if ((p = (void *)malloc(t->bt_psize)) == NULL)
< return (RET_ERROR);
< if ((h = mpool_get(t->bt_mp, t->bt_bcursor.pgno, 0)) == NULL)
< return (RET_ERROR);
< memmove(p, h, t->bt_psize);
< if ((status =
< __bt_dleaf(t, h, t->bt_bcursor.index)) == RET_ERROR)
< goto ecrsr;
< mpool_put(t->bt_mp, h, MPOOL_DIRTY);
< }
<
162c147
< CLR(t, B_MODIFIED);
---
> F_CLR(t, B_MODIFIED);
164,170d148
< ecrsr: if (ISSET(t, B_DELCRSR)) {
< if ((h = mpool_get(t->bt_mp, t->bt_bcursor.pgno, 0)) == NULL)
< return (RET_ERROR);
< memmove(h, p, t->bt_psize);
< free(p);
< mpool_put(t->bt_mp, h, MPOOL_DIRTY);
< }
194,199c172,177
< m.m_magic = BTREEMAGIC;
< m.m_version = BTREEVERSION;
< m.m_psize = t->bt_psize;
< m.m_free = t->bt_free;
< m.m_nrecs = t->bt_nrecs;
< m.m_flags = t->bt_flags & SAVEMETA;
---
> m.magic = BTREEMAGIC;
> m.version = BTREEVERSION;
> m.psize = t->bt_psize;
> m.free = t->bt_free;
> m.nrecs = t->bt_nrecs;
> m.flags = F_ISSET(t, SAVEMETA);