Skip to content

Commit 64dbe37

Browse files
author
Konstantin Osipov
committed
Backport of:
---------------------------------------------------------- revno: 2617.22.5 committer: Konstantin Osipov <[email protected]> branch nick: mysql-6.0-runtime timestamp: Tue 2009-01-27 05:08:48 +0300 message: Remove non-prefixed use of HASH. Always use my_hash_init(), my_hash_inited(), my_hash_search(), my_hash_element(), my_hash_delete(), my_hash_free() rather than non-prefixed counterparts (hash_init(), etc). Remove the backward-compatible defines.
1 parent 902f99b commit 64dbe37

44 files changed

Lines changed: 561 additions & 578 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

client/mysqldump.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -861,9 +861,9 @@ static int get_options(int *argc, char ***argv)
861861
load_defaults("my",load_default_groups,argc,argv);
862862
defaults_argv= *argv;
863863

864-
if (hash_init(&ignore_table, charset_info, 16, 0, 0,
865-
(hash_get_key) get_table_key,
866-
(hash_free_key) free_table_ent, 0))
864+
if (my_hash_init(&ignore_table, charset_info, 16, 0, 0,
865+
(my_hash_get_key) get_table_key,
866+
(my_hash_free_key) free_table_ent, 0))
867867
return(EX_EOM);
868868
/* Don't copy internal log tables */
869869
if (my_hash_insert(&ignore_table,
@@ -1367,8 +1367,8 @@ static void free_resources()
13671367
if (md_result_file && md_result_file != stdout)
13681368
my_fclose(md_result_file, MYF(0));
13691369
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
1370-
if (hash_inited(&ignore_table))
1371-
hash_free(&ignore_table);
1370+
if (my_hash_inited(&ignore_table))
1371+
my_hash_free(&ignore_table);
13721372
if (extended_insert)
13731373
dynstr_free(&extended_row);
13741374
if (insert_pat_inited)
@@ -3958,7 +3958,7 @@ static int init_dumping(char *database, int init_func(char*))
39583958

39593959
my_bool include_table(const uchar *hash_key, size_t len)
39603960
{
3961-
return !hash_search(&ignore_table, hash_key, len);
3961+
return ! my_hash_search(&ignore_table, hash_key, len);
39623962
}
39633963

39643964

client/mysqltest.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ void free_used_memory()
11351135

11361136
close_connections();
11371137
close_files();
1138-
hash_free(&var_hash);
1138+
my_hash_free(&var_hash);
11391139

11401140
for (i= 0 ; i < q_lines.elements ; i++)
11411141
{
@@ -1998,8 +1998,8 @@ VAR* var_get(const char *var_name, const char **var_name_end, my_bool raw,
19981998
if (length >= MAX_VAR_NAME_LENGTH)
19991999
die("Too long variable name: %s", save_var_name);
20002000

2001-
if (!(v = (VAR*) hash_search(&var_hash, (const uchar*) save_var_name,
2002-
length)))
2001+
if (!(v = (VAR*) my_hash_search(&var_hash, (const uchar*) save_var_name,
2002+
length)))
20032003
{
20042004
char buff[MAX_VAR_NAME_LENGTH+1];
20052005
strmake(buff, save_var_name, length);
@@ -2030,7 +2030,7 @@ VAR* var_get(const char *var_name, const char **var_name_end, my_bool raw,
20302030
VAR *var_obtain(const char *name, int len)
20312031
{
20322032
VAR* v;
2033-
if ((v = (VAR*)hash_search(&var_hash, (const uchar *) name, len)))
2033+
if ((v = (VAR*)my_hash_search(&var_hash, (const uchar *) name, len)))
20342034
return v;
20352035
v = var_init(0, name, len, "", 0);
20362036
my_hash_insert(&var_hash, (uchar*)v);
@@ -7580,8 +7580,8 @@ int main(int argc, char **argv)
75807580

75817581
my_init_dynamic_array(&q_lines, sizeof(struct st_command*), 1024, 1024);
75827582

7583-
if (hash_init(&var_hash, charset_info,
7584-
1024, 0, 0, get_var_key, var_free, MYF(0)))
7583+
if (my_hash_init(&var_hash, charset_info,
7584+
1024, 0, 0, get_var_key, var_free, MYF(0)))
75857585
die("Variable hash initialization failed");
75867586

75877587
var_set_string("$MYSQL_SERVER_VERSION", MYSQL_SERVER_VERSION);

include/hash.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,40 +21,6 @@
2121
extern "C" {
2222
#endif
2323

24-
/*
25-
There was a problem on MacOSX with a shared object ha_example.so.
26-
It used hash_search(). During build of ha_example.so no libmysys
27-
was specified. Since MacOSX had a hash_search() in the system
28-
library, it built the shared object so that the dynamic linker
29-
linked hash_search() to the system library, which caused a crash
30-
when called. To come around this, we renamed hash_search() to
31-
my_hash_search(), as we did long ago with hash_insert() and
32-
hash_reset(). However, this time we made the move complete with
33-
all names. To keep compatibility, we redefine the old names.
34-
Since every C and C++ file, that uses HASH, needs to include
35-
this file, the change is complete. Both names could be used
36-
in the code, but the my_* versions are recommended now.
37-
*/
38-
#define hash_get_key my_hash_get_key
39-
#define hash_free_key my_hash_free_key
40-
#define hash_init my_hash_init
41-
#define hash_init2 my_hash_init2
42-
#define _hash_init _my_hash_init
43-
#define hash_free my_hash_free
44-
#define hash_reset my_hash_reset
45-
#define hash_element my_hash_element
46-
#define hash_search my_hash_search
47-
#define hash_first my_hash_first
48-
#define hash_next my_hash_next
49-
#define hash_insert my_hash_insert
50-
#define hash_delete my_hash_delete
51-
#define hash_update my_hash_update
52-
#define hash_replace my_hash_replace
53-
#define hash_check my_hash_check
54-
#define hash_clear my_hash_clear
55-
#define hash_inited my_hash_inited
56-
#define hash_init_opt my_hash_init_opt
57-
5824
/*
5925
Overhead to store an element in hash
6026
Can be used to approximate memory consumption for a hash

mysys/mf_keycaches.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ static my_bool safe_hash_init(SAFE_HASH *hash, uint elements,
108108
uchar *default_value)
109109
{
110110
DBUG_ENTER("safe_hash");
111-
if (hash_init(&hash->hash, &my_charset_bin, elements,
112-
0, 0, (hash_get_key) safe_hash_entry_get,
113-
(void (*)(void*)) safe_hash_entry_free, 0))
111+
if (my_hash_init(&hash->hash, &my_charset_bin, elements,
112+
0, 0, (my_hash_get_key) safe_hash_entry_get,
113+
(void (*)(void*)) safe_hash_entry_free, 0))
114114
{
115115
hash->default_value= 0;
116116
DBUG_RETURN(1);
@@ -137,7 +137,7 @@ static void safe_hash_free(SAFE_HASH *hash)
137137
*/
138138
if (hash->default_value)
139139
{
140-
hash_free(&hash->hash);
140+
my_hash_free(&hash->hash);
141141
rwlock_destroy(&hash->mutex);
142142
hash->default_value=0;
143143
}
@@ -152,7 +152,7 @@ static uchar *safe_hash_search(SAFE_HASH *hash, const uchar *key, uint length)
152152
uchar *result;
153153
DBUG_ENTER("safe_hash_search");
154154
rw_rdlock(&hash->mutex);
155-
result= hash_search(&hash->hash, key, length);
155+
result= my_hash_search(&hash->hash, key, length);
156156
rw_unlock(&hash->mutex);
157157
if (!result)
158158
result= hash->default_value;
@@ -192,7 +192,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const uchar *key, uint length,
192192
DBUG_PRINT("enter",("key: %.*s data: 0x%lx", length, key, (long) data));
193193

194194
rw_wrlock(&hash->mutex);
195-
entry= (SAFE_HASH_ENTRY*) hash_search(&hash->hash, key, length);
195+
entry= (SAFE_HASH_ENTRY*) my_hash_search(&hash->hash, key, length);
196196

197197
if (data == hash->default_value)
198198
{
@@ -206,7 +206,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const uchar *key, uint length,
206206
/* unlink entry from list */
207207
if ((*entry->prev= entry->next))
208208
entry->next->prev= entry->prev;
209-
hash_delete(&hash->hash, (uchar*) entry);
209+
my_hash_delete(&hash->hash, (uchar*) entry);
210210
goto end;
211211
}
212212
if (entry)
@@ -277,7 +277,7 @@ static void safe_hash_change(SAFE_HASH *hash, uchar *old_data, uchar *new_data)
277277
{
278278
if ((*entry->prev= entry->next))
279279
entry->next->prev= entry->prev;
280-
hash_delete(&hash->hash, (uchar*) entry);
280+
my_hash_delete(&hash->hash, (uchar*) entry);
281281
}
282282
else
283283
entry->data= new_data;

0 commit comments

Comments
 (0)