/* * __free_page_row_leaf -- * Discard a WT_PAGE_ROW_LEAF page. */ static void __free_page_row_leaf(WT_SESSION_IMPL *session, WT_PAGE *page) { WT_IKEY *ikey; WT_ROW *rip; uint32_t i; /* * Free the in-memory index array. * * For each entry, see if the key was an allocation (that is, if it * points somewhere other than the original page), and if so, free * the memory. */ WT_ROW_FOREACH(page, rip, i) if ((ikey = rip->key) != NULL && __wt_off_page(page, ikey)) __wt_free(session, ikey); __wt_free(session, page->u.row.d); /* * Free the insert array. * * Row-store tables have one additional slot in the insert array (the * insert array has an extra slot to hold keys that sort before keys * found on the original page). */ if (page->u.row.ins != NULL) __free_skip_array(session, page->u.row.ins, page->entries + 1); /* Free the update array. */ if (page->u.row.upd != NULL) __free_update(session, page->u.row.upd, page->entries); }
/* * __free_page_modify -- * Discard the page's associated modification structures. */ static void __free_page_modify(WT_SESSION_IMPL *session, WT_PAGE *page) { WT_INSERT_HEAD *append; WT_MULTI *multi; WT_PAGE_MODIFY *mod; uint32_t i; bool update_ignore; mod = page->modify; /* In some failed-split cases, we can't discard updates. */ update_ignore = F_ISSET_ATOMIC(page, WT_PAGE_UPDATE_IGNORE); switch (mod->rec_result) { case WT_PM_REC_MULTIBLOCK: /* Free list of replacement blocks. */ for (multi = mod->mod_multi, i = 0; i < mod->mod_multi_entries; ++multi, ++i) { switch (page->type) { case WT_PAGE_ROW_INT: case WT_PAGE_ROW_LEAF: __wt_free(session, multi->key.ikey); break; } __wt_free(session, multi->supd); __wt_free(session, multi->disk_image); __wt_free(session, multi->addr.addr); } __wt_free(session, mod->mod_multi); break; case WT_PM_REC_REPLACE: /* * Discard any replacement address: this memory is usually moved * into the parent's WT_REF, but at the root that can't happen. */ __wt_free(session, mod->mod_replace.addr); break; } switch (page->type) { case WT_PAGE_COL_FIX: case WT_PAGE_COL_VAR: /* Free the append array. */ if ((append = WT_COL_APPEND(page)) != NULL) { __free_skip_list( session, WT_SKIP_FIRST(append), update_ignore); __wt_free(session, append); __wt_free(session, mod->mod_col_append); } /* Free the insert/update array. */ if (mod->mod_col_update != NULL) __free_skip_array(session, mod->mod_col_update, page->type == WT_PAGE_COL_FIX ? 1 : page->pg_var_entries, update_ignore); break; case WT_PAGE_ROW_LEAF: /* * Free the insert array. * * Row-store tables have one additional slot in the insert array * (the insert array has an extra slot to hold keys that sort * before keys found on the original page). */ if (mod->mod_row_insert != NULL) __free_skip_array(session, mod->mod_row_insert, page->pg_row_entries + 1, update_ignore); /* Free the update array. */ if (mod->mod_row_update != NULL) __free_update(session, mod->mod_row_update, page->pg_row_entries, update_ignore); break; } /* Free the overflow on-page, reuse and transaction-cache skiplists. */ __wt_ovfl_reuse_free(session, page); __wt_ovfl_txnc_free(session, page); __wt_ovfl_discard_free(session, page); __wt_free(session, page->modify->ovfl_track); __wt_free(session, page->modify); }