Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
4662631f
Commit
4662631f
authored
Jun 19, 2009
by
V Narayanan
Browse files
Options
Browse Files
Download
Plain Diff
merging with mysql-5.0-bugteam
parents
18bd3cd5
336c8106
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
8 deletions
+30
-8
include/hash.h
include/hash.h
+1
-1
mysys/hash.c
mysys/hash.c
+29
-7
No files found.
include/hash.h
View file @
4662631f
...
...
@@ -106,7 +106,7 @@ void my_hash_replace(HASH *hash, HASH_SEARCH_STATE *state, uchar *new_row);
my_bool
my_hash_check
(
HASH
*
hash
);
/* Only in debug library */
#define my_hash_clear(H) bzero((char*) (H), sizeof(*(H)))
#define my_hash_inited(H) ((H)->
array.buffer
!= 0)
#define my_hash_inited(H) ((H)->
blength
!= 0)
#define my_hash_init_opt(A,B,C,D,E,F,G,H) \
(!my_hash_inited(A) && _my_hash_init(A,0,B,C,D,E,F,G, H CALLER_INFO))
...
...
mysys/hash.c
View file @
4662631f
...
...
@@ -45,6 +45,32 @@ static uint calc_hash(const HASH *hash, const uchar *key, size_t length)
return
nr1
;
}
/**
@brief Initialize the hash
@details
Initialize the hash, by defining and giving valid values for
its elements. The failure to allocate memory for the
hash->array element will not result in a fatal failure. The
dynamic array that is part of the hash will allocate memory
as required during insertion.
@param[in,out] hash The hash that is initialized
@param[in] charset The charater set information
@param[in] size The hash size
@param[in] key_offest The key offset for the hash
@param[in] key_length The length of the key used in
the hash
@param[in] get_key get the key for the hash
@param[in] free_element pointer to the function that
does cleanup
@param[in] CALLER_INFO_PROTO flag that define the behaviour
of the hash
@return inidicates success or failure of initialization
@retval 0 success
@retval 1 failure
*/
my_bool
_my_hash_init
(
HASH
*
hash
,
uint
growth_size
,
CHARSET_INFO
*
charset
,
ulong
size
,
size_t
key_offset
,
size_t
key_length
,
...
...
@@ -55,12 +81,6 @@ _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset,
DBUG_PRINT
(
"enter"
,(
"hash: 0x%lx size: %u"
,
(
long
)
hash
,
(
uint
)
size
));
hash
->
records
=
0
;
if
(
my_init_dynamic_array_ci
(
&
hash
->
array
,
sizeof
(
HASH_LINK
),
size
,
growth_size
))
{
hash
->
free
=
0
;
/* Allow call to my_hash_free */
DBUG_RETURN
(
1
);
}
hash
->
key_offset
=
key_offset
;
hash
->
key_length
=
key_length
;
hash
->
blength
=
1
;
...
...
@@ -68,7 +88,8 @@ _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset,
hash
->
free
=
free_element
;
hash
->
flags
=
flags
;
hash
->
charset
=
charset
;
DBUG_RETURN
(
0
);
DBUG_RETURN
(
my_init_dynamic_array_ci
(
&
hash
->
array
,
sizeof
(
HASH_LINK
),
size
,
0
));
}
...
...
@@ -114,6 +135,7 @@ void my_hash_free(HASH *hash)
my_hash_free_elements
(
hash
);
hash
->
free
=
0
;
delete_dynamic
(
&
hash
->
array
);
hash
->
blength
=
0
;
DBUG_VOID_RETURN
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment