/* * __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_col_fix -- * Discard a WT_PAGE_COL_FIX page. */ static void __free_page_col_fix(WT_SESSION_IMPL *session, WT_PAGE *page) { WT_INSERT_HEAD *append; /* Free the append array. */ if ((append = WT_COL_APPEND(page)) != NULL) { __free_skip_list(session, WT_SKIP_FIRST(append)); __wt_free(session, append); __wt_free(session, page->modify->append); } /* Free the update array. */ if (page->modify != NULL && page->modify->update != NULL) __free_skip_array(session, page->modify->update, 1); }
/* * __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_PAGE_MODIFY *mod; mod = page->modify; switch (F_ISSET(mod, WT_PM_REC_MASK)) { case WT_PM_REC_SPLIT: /* * If the page split, there may one or more pages linked from * the page; walk the list, discarding pages. */ __wt_page_out(session, &mod->u.split); 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->u.replace.addr); break; default: break; } /* Free the append array. */ if ((append = WT_COL_APPEND(page)) != NULL) { __free_skip_list(session, WT_SKIP_FIRST(append)); __wt_free(session, append); __wt_free(session, mod->append); } /* Free the insert/update array. */ if (mod->update != NULL) __free_skip_array(session, mod->update, page->type == WT_PAGE_COL_FIX ? 1 : page->entries); /* Discard any objects the page was tracking plus associated memory. */ __wt_rec_track_discard(session, page); __wt_free(session, mod->track); __wt_free(session, page->modify); }
/* * __free_page_col_var -- * Discard a WT_PAGE_COL_VAR page. */ static void __free_page_col_var(WT_SESSION_IMPL *session, WT_PAGE *page) { WT_INSERT_HEAD *append; /* Free the in-memory index array. */ __wt_free(session, page->u.col_var.d); /* Free the RLE lookup array. */ __wt_free(session, page->u.col_var.repeats); /* Free the append array. */ if ((append = WT_COL_APPEND(page)) != NULL) { __free_skip_list(session, WT_SKIP_FIRST(append)); __wt_free(session, append); __wt_free(session, page->modify->append); } /* Free the insert array. */ if (page->modify != NULL && page->modify->update != NULL) __free_skip_array(session, page->modify->update, 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_append); } /* Free the insert/update array. */ if (mod->mod_update != NULL) __free_skip_array(session, mod->mod_update, page->type == WT_PAGE_COL_FIX ? 1 : page->pg_var_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); }