Commit 16d8367a authored by Sergei Golubchik's avatar Sergei Golubchik

List<>-style template wrapper over hash_filo

parent 94c97e5b
......@@ -199,4 +199,17 @@ public:
}
};
template <class T> class Hash_filo: public hash_filo
{
public:
Hash_filo(uint size_arg, uint key_offset_arg, uint key_length_arg,
my_hash_get_key get_key_arg, my_hash_free_key free_element_arg,
CHARSET_INFO *hash_charset_arg) :
hash_filo(size_arg, key_offset_arg, key_length_arg,
get_key_arg, free_element_arg, hash_charset_arg) {}
T* first() { return (T*)hash_filo::first(); }
T* last() { return (T*)hash_filo::last(); }
T* search(uchar* key, size_t len) { return (T*)hash_filo::search(key, len); }
};
#endif
......@@ -126,7 +126,7 @@ void Host_errors::aggregate(const Host_errors *errors)
m_local+= errors->m_local;
}
static hash_filo *hostname_cache;
static Hash_filo<Host_entry> *hostname_cache;
ulong host_cache_size;
void hostname_cache_refresh()
......@@ -149,7 +149,7 @@ bool hostname_cache_init()
Host_entry tmp;
uint key_offset= (uint) ((char*) (&tmp.ip_key) - (char*) &tmp);
if (!(hostname_cache= new hash_filo(host_cache_size,
if (!(hostname_cache= new Hash_filo<Host_entry>(host_cache_size,
key_offset, HOST_ENTRY_KEY_SIZE,
NULL, (my_hash_free_key) free,
&my_charset_bin)))
......@@ -187,11 +187,11 @@ static void prepare_hostname_cache_key(const char *ip_string,
}
Host_entry *hostname_cache_first()
{ return (Host_entry *) hostname_cache->first(); }
{ return hostname_cache->first(); }
static inline Host_entry *hostname_cache_search(const char *ip_key)
{
return (Host_entry *) hostname_cache->search((uchar *) ip_key, 0);
return hostname_cache->search((uchar *) ip_key, 0);
}
static void add_hostname_impl(const char *ip_key, const char *hostname,
......
......@@ -727,7 +727,7 @@ static bool initialized=0;
static bool allow_all_hosts=1;
static HASH acl_check_hosts, column_priv_hash, proc_priv_hash, func_priv_hash;
static DYNAMIC_ARRAY acl_wild_hosts;
static hash_filo *acl_cache;
static Hash_filo<acl_entry> *acl_cache;
static uint grant_version=0; /* Version of priv tables. incremented by acl_load */
static ulong get_access(TABLE *form,uint fieldnr, uint *next_field=0);
static bool check_is_role(TABLE *form);
......@@ -924,7 +924,7 @@ my_bool acl_init(bool dont_read_acl_tables)
my_bool return_val;
DBUG_ENTER("acl_init");
acl_cache= new hash_filo(ACL_CACHE_SIZE, 0, 0,
acl_cache= new Hash_filo<acl_entry>(ACL_CACHE_SIZE, 0, 0,
(my_hash_get_key) acl_entry_get_key,
(my_hash_free_key) free,
&my_charset_utf8_bin);
......@@ -2182,8 +2182,7 @@ ulong acl_get(const char *host, const char *ip,
key_length= (size_t) (end-key);
mysql_mutex_lock(&acl_cache->lock);
if (!db_is_pattern && (entry=(acl_entry*) acl_cache->search((uchar*) key,
key_length)))
if (!db_is_pattern && (entry=acl_cache->search((uchar*) key, key_length)))
{
db_access=entry->access;
mysql_mutex_unlock(&acl_cache->lock);
......
......@@ -38,7 +38,6 @@
#include "unireg.h"
#include "sql_base.h" // close_mysql_tables
#include "records.h" // init_read_record, end_read_record
#include "hash_filo.h"
#include <m_ctype.h>
#include <stdarg.h>
#include "sp_head.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment