diff options
author | monty@mysql.com/narttu.mysql.fi <> | 2007-05-10 12:59:39 +0300 |
---|---|---|
committer | monty@mysql.com/narttu.mysql.fi <> | 2007-05-10 12:59:39 +0300 |
commit | 088e2395f1833f16c2ea3f7405f604165b4aa2cc (patch) | |
tree | 6480cbef09e9dec2fa347b1899963ab3658d692f /storage/example | |
parent | 9078e630c64a313301cd13ce71d0854fbcf2fd0b (diff) | |
download | mariadb-git-088e2395f1833f16c2ea3f7405f604165b4aa2cc.tar.gz |
WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:
- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t
Removed declaration of byte, gptr, my_string, my_size_t and size_s.
Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
as this requires fewer casts in the code and is more in line with how the
standard functions work.
- Added extra length argument to dirname_part() to return the length of the
created string.
- Changed (at least) following functions to take uchar* as argument:
- db_dump()
- my_net_write()
- net_write_command()
- net_store_data()
- DBUG_DUMP()
- decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
argument to my_uncompress() from a pointer to a value as we only return
one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.
Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
explicitely as this conflict was often hided by casting the function to
hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
size_t. This was needed to properly detect errors (which are
returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
(portability fix)
- Removed windows specific code to restore cursor position as this
causes slowdown on windows and we should not mix read() and pread()
calls anyway as this is not thread safe. Updated function comment to
reflect this. Changed function that depended on original behavior of
my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
m_size is the number of elements in the array, not a string/memory
length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
- Replaced some calls to alloc_root + memcpy to use
strmake_root()/strdup_root().
- Changed some calls from memdup() to strmake() (Safety fix)
- Simpler loops in client-simple.c
Diffstat (limited to 'storage/example')
-rw-r--r-- | storage/example/ha_example.cc | 36 | ||||
-rw-r--r-- | storage/example/ha_example.h | 22 |
2 files changed, 29 insertions, 29 deletions
diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index a4cdcafc6d0..45433fd58ce 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -114,11 +114,11 @@ pthread_mutex_t example_mutex; Function we use in the creation of our hash to get key. */ -static byte* example_get_key(EXAMPLE_SHARE *share,uint *length, +static uchar* example_get_key(EXAMPLE_SHARE *share,uint *length, my_bool not_used __attribute__((unused))) { *length=share->table_name_length; - return (byte*) share->table_name; + return (uchar*) share->table_name; } @@ -172,7 +172,7 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table) length=(uint) strlen(table_name); if (!(share=(EXAMPLE_SHARE*) hash_search(&example_open_tables, - (byte*) table_name, + (uchar*) table_name, length))) { if (!(share=(EXAMPLE_SHARE *) @@ -189,7 +189,7 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table) share->table_name_length=length; share->table_name=tmp_name; strmov(share->table_name,table_name); - if (my_hash_insert(&example_open_tables, (byte*) share)) + if (my_hash_insert(&example_open_tables, (uchar*) share)) goto error; thr_lock_init(&share->lock); pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST); @@ -201,7 +201,7 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table) error: pthread_mutex_destroy(&share->mutex); - my_free((gptr) share, MYF(0)); + my_free(share, MYF(0)); return NULL; } @@ -218,10 +218,10 @@ static int free_share(EXAMPLE_SHARE *share) pthread_mutex_lock(&example_mutex); if (!--share->use_count) { - hash_delete(&example_open_tables, (byte*) share); + hash_delete(&example_open_tables, (uchar*) share); thr_lock_delete(&share->lock); pthread_mutex_destroy(&share->mutex); - my_free((gptr) share, MYF(0)); + my_free(share, MYF(0)); } pthread_mutex_unlock(&example_mutex); @@ -349,7 +349,7 @@ int ha_example::close(void) sql_insert.cc, sql_select.cc, sql_table.cc, sql_udf.cc and sql_update.cc */ -int ha_example::write_row(byte * buf) +int ha_example::write_row(uchar *buf) { DBUG_ENTER("ha_example::write_row"); DBUG_RETURN(HA_ERR_WRONG_COMMAND); @@ -378,7 +378,7 @@ int ha_example::write_row(byte * buf) @see sql_select.cc, sql_acl.cc, sql_update.cc and sql_insert.cc */ -int ha_example::update_row(const byte * old_data, byte * new_data) +int ha_example::update_row(const uchar *old_data, uchar *new_data) { DBUG_ENTER("ha_example::update_row"); @@ -406,7 +406,7 @@ int ha_example::update_row(const byte * old_data, byte * new_data) sql_acl.cc, sql_udf.cc, sql_delete.cc, sql_insert.cc and sql_select.cc */ -int ha_example::delete_row(const byte * buf) +int ha_example::delete_row(const uchar *buf) { DBUG_ENTER("ha_example::delete_row"); DBUG_RETURN(HA_ERR_WRONG_COMMAND); @@ -420,7 +420,7 @@ int ha_example::delete_row(const byte * buf) index. */ -int ha_example::index_read(byte * buf, const byte * key, +int ha_example::index_read(uchar *buf, const uchar *key, key_part_map keypart_map __attribute__((unused)), enum ha_rkey_function find_flag __attribute__((unused))) @@ -435,7 +435,7 @@ int ha_example::index_read(byte * buf, const byte * key, Used to read forward through the index. */ -int ha_example::index_next(byte * buf) +int ha_example::index_next(uchar *buf) { DBUG_ENTER("ha_example::index_next"); DBUG_RETURN(HA_ERR_WRONG_COMMAND); @@ -447,7 +447,7 @@ int ha_example::index_next(byte * buf) Used to read backwards through the index. */ -int ha_example::index_prev(byte * buf) +int ha_example::index_prev(uchar *buf) { DBUG_ENTER("ha_example::index_prev"); DBUG_RETURN(HA_ERR_WRONG_COMMAND); @@ -464,7 +464,7 @@ int ha_example::index_prev(byte * buf) @see opt_range.cc, opt_sum.cc, sql_handler.cc and sql_select.cc */ -int ha_example::index_first(byte * buf) +int ha_example::index_first(uchar *buf) { DBUG_ENTER("ha_example::index_first"); DBUG_RETURN(HA_ERR_WRONG_COMMAND); @@ -481,7 +481,7 @@ int ha_example::index_first(byte * buf) @see opt_range.cc, opt_sum.cc, sql_handler.cc and sql_select.cc */ -int ha_example::index_last(byte * buf) +int ha_example::index_last(uchar *buf) { DBUG_ENTER("ha_example::index_last"); DBUG_RETURN(HA_ERR_WRONG_COMMAND); @@ -528,7 +528,7 @@ int ha_example::rnd_end() @see filesort.cc, records.cc, sql_handler.cc, sql_select.cc, sql_table.cc and sql_update.cc */ -int ha_example::rnd_next(byte *buf) +int ha_example::rnd_next(uchar *buf) { DBUG_ENTER("ha_example::rnd_next"); DBUG_RETURN(HA_ERR_END_OF_FILE); @@ -556,7 +556,7 @@ int ha_example::rnd_next(byte *buf) @see filesort.cc, sql_select.cc, sql_delete.cc and sql_update.cc */ -void ha_example::position(const byte *record) +void ha_example::position(const uchar *record) { DBUG_ENTER("ha_example::position"); DBUG_VOID_RETURN; @@ -576,7 +576,7 @@ void ha_example::position(const byte *record) @see filesort.cc, records.cc, sql_insert.cc, sql_select.cc and sql_update.cc */ -int ha_example::rnd_pos(byte * buf, byte *pos) +int ha_example::rnd_pos(uchar *buf, uchar *pos) { DBUG_ENTER("ha_example::rnd_pos"); DBUG_RETURN(HA_ERR_WRONG_COMMAND); diff --git a/storage/example/ha_example.h b/storage/example/ha_example.h index 9777a478209..69b7cf4d336 100644 --- a/storage/example/ha_example.h +++ b/storage/example/ha_example.h @@ -172,50 +172,50 @@ public: We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int write_row(byte * buf); + int write_row(uchar *buf); /** @brief We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int update_row(const byte * old_data, byte * new_data); + int update_row(const uchar *old_data, uchar *new_data); /** @brief We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int delete_row(const byte * buf); + int delete_row(const uchar *buf); /** @brief We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int index_read(byte * buf, const byte * key, + int index_read(uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag); /** @brief We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int index_next(byte * buf); + int index_next(uchar *buf); /** @brief We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int index_prev(byte * buf); + int index_prev(uchar *buf); /** @brief We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int index_first(byte * buf); + int index_first(uchar *buf); /** @brief We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int index_last(byte * buf); + int index_last(uchar *buf); /** @brief Unlike index_init(), rnd_init() can be called two consecutive times @@ -227,9 +227,9 @@ public: */ int rnd_init(bool scan); //required int rnd_end(); - int rnd_next(byte *buf); ///< required - int rnd_pos(byte * buf, byte *pos); ///< required - void position(const byte *record); ///< required + int rnd_next(uchar *buf); ///< required + int rnd_pos(uchar *buf, uchar *pos); ///< required + void position(const uchar *record); ///< required int info(uint); ///< required int extra(enum ha_extra_function operation); int external_lock(THD *thd, int lock_type); ///< required |