diff options
author | Sergey Vojtovich <svoj@sun.com> | 2009-07-14 15:06:04 +0500 |
---|---|---|
committer | Sergey Vojtovich <svoj@sun.com> | 2009-07-14 15:06:04 +0500 |
commit | 058cd6256557165d4b8a059c071eaea91d39d2b7 (patch) | |
tree | 74e564b644c182b72bd6b9ad0cc93ae70454e898 /mysys | |
parent | 1c2c168c6641023edce3f0f55e4d2fe8ee788958 (diff) | |
parent | 62a4848d09f8fc81e35127ffe07d431fb8a2a60c (diff) | |
download | mariadb-git-058cd6256557165d4b8a059c071eaea91d39d2b7.tar.gz |
Merge 5.1-bugteam -> 5.1-innodb_plugin.
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/hash.c | 36 | ||||
-rw-r--r-- | mysys/my_getopt.c | 15 |
2 files changed, 42 insertions, 9 deletions
diff --git a/mysys/hash.c b/mysys/hash.c index e7b5352af34..63933abb085 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -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, growth_size)); } @@ -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; } diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 33942d87e4f..fd3c2501226 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -20,6 +20,7 @@ #include <mysys_err.h> #include <my_getopt.h> #include <errno.h> +#include <m_string.h> typedef void (*init_func_p)(const struct my_option *option, uchar* *variable, longlong value); @@ -649,8 +650,18 @@ static int setval(const struct my_option *opts, uchar* *value, char *argument, return EXIT_OUT_OF_MEMORY; break; case GET_ENUM: - if (((*(int*)result_pos)= find_type(argument, opts->typelib, 2) - 1) < 0) - return EXIT_ARGUMENT_INVALID; + if (((*(int*)result_pos)= + find_type(argument, opts->typelib, 2) - 1) < 0) + { + /* + Accept an integer representation of the enumerated item. + */ + char *endptr; + unsigned int arg= (unsigned int) strtol(argument, &endptr, 10); + if (*endptr || arg >= opts->typelib->count) + return EXIT_ARGUMENT_INVALID; + *(int*)result_pos= arg; + } break; case GET_SET: *((ulonglong*)result_pos)= find_typeset(argument, opts->typelib, &err); |