summaryrefslogtreecommitdiff
path: root/storage/xtradb/ha/hash0hash.c
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2010-09-11 20:43:48 +0200
committerSergei Golubchik <sergii@pisem.net>2010-09-11 20:43:48 +0200
commita3d80d952d7b99680ca4a3a89e128ecc0d490c10 (patch)
tree0d72ee69e037cdd09618ddb53652dd1b220890dc /storage/xtradb/ha/hash0hash.c
parentec06ba24553d2d83b3a6a6bc4d8150910b01ee7c (diff)
parent966661c8cc75dd7d540a5fe40b4d893c40e91d26 (diff)
downloadmariadb-git-a3d80d952d7b99680ca4a3a89e128ecc0d490c10.tar.gz
merge with 5.1
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..70516deb005 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*)(((char*)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*)(((char*)table) + offset);
+ ut_ad(table->magic_n == HASH_TABLE_MAGIC_N);
+}
+
+/*************************************************************//**
Frees a hash table. */
UNIV_INTERN
void