summaryrefslogtreecommitdiff
path: root/storage/xtradb/ha/hash0hash.c
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2011-02-22 15:15:17 +0200
committerMichael Widenius <monty@askmonty.org>2011-02-22 15:15:17 +0200
commitb35743f9877fc826372eeb6dec21665aa3ff32f4 (patch)
tree4361a08c36980010723e75e1bc79c974139e0d6c /storage/xtradb/ha/hash0hash.c
parent58bb0769bdf13a9747e900aa2f0955137738ce9d (diff)
parente69b70140b936f59826de9dc79e4bf7f4821d52e (diff)
downloadmariadb-git-b35743f9877fc826372eeb6dec21665aa3ff32f4.tar.gz
Merge with xtradb code changes
(4 tests are still failing, so this push is not yet stable)
Diffstat (limited to 'storage/xtradb/ha/hash0hash.c')
-rw-r--r--storage/xtradb/ha/hash0hash.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/storage/xtradb/ha/hash0hash.c b/storage/xtradb/ha/hash0hash.c
index 30c304dafcd..0f4fc55d895 100644
--- a/storage/xtradb/ha/hash0hash.c
+++ b/storage/xtradb/ha/hash0hash.c
@@ -128,6 +128,70 @@ hash_create(
}
/*************************************************************//**
+*/
+UNIV_INTERN
+ulint
+hash_create_needed(
+/*===============*/
+ ulint n)
+{
+ ulint prime;
+ ulint offset;
+
+ prime = ut_find_prime(n);
+
+ offset = (sizeof(hash_table_t) + 7) / 8;
+ offset *= 8;
+
+ return(offset + sizeof(hash_cell_t) * prime);
+}
+
+UNIV_INTERN
+void
+hash_create_init(
+/*=============*/
+ hash_table_t* table,
+ ulint n)
+{
+ ulint prime;
+ ulint offset;
+
+ prime = ut_find_prime(n);
+
+ offset = (sizeof(hash_table_t) + 7) / 8;
+ offset *= 8;
+
+ table->array = (hash_cell_t*)(((byte*)table) + offset);
+ table->n_cells = prime;
+# if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
+ table->adaptive = FALSE;
+# endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
+ table->n_mutexes = 0;
+ table->mutexes = NULL;
+ table->heaps = NULL;
+ table->heap = NULL;
+ ut_d(table->magic_n = HASH_TABLE_MAGIC_N);
+
+ /* Initialize the cell array */
+ hash_table_clear(table);
+}
+
+UNIV_INTERN
+void
+hash_create_reuse(
+/*==============*/
+ hash_table_t* table)
+{
+ ulint offset;
+
+ offset = (sizeof(hash_table_t) + 7) / 8;
+ offset *= 8;
+
+ table->array = (hash_cell_t*)(((byte*)table) + offset);
+ ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
+}
+
+/*************************************************************//**
Frees a hash table. */
UNIV_INTERN
void