WL#3817: Simplify string / memory area types and make things more consistent
Affects: Server-5.1
—
Status: Complete
The reasons for this change are: - To get rid of 'byte', which is declared differently on different OS. (This is one of the common causes for compiler problems on Windows) - Get rid of my_string because: - This is hard to use with 'const' - It's not used consistently. - To get rid of a lot of casts between char *, byte * and uchar *. (This is a potential area of bugs, where we have had several bugs in the' past). - To get rid of potential bugs on operating systems where byte is declared as signed but we still assume that we can get a number 0-255 by referencing a byte * variable. - Get rid of gptr, as internally we don't have a good understanding of it's need. - Get rid of a lot of compiler warnings on windows 64 bit when we use uint with string functions. - To make the code more readable by introducing the following semantics: - 'char *' points to a string area that is \0 terminated. - 'void *' points to a general memory area that needs to be cast to be used. Examples: Pointer to functions, structs, objects etc. - LEX_STRING is a string object (of my_byte*) that has a pointer. Over time we should move most things to this. - Ensure we can handle bigger memory areas on 64 bit systems. This change needs to be done at a very late stage of a tree as this will have an impact of merges.
This task originally was: Change uchar *, byte * to my_byte *.. and change my_string to char * Now the task is: Simplify our string / memory area types and make things more consistent. In short the changes should be: Replace byte * with uchar * Change my_string to char * Change my_size_t to size_t Only use char * for strings that ends with a \0 Get rid of types my_size_t, gptr, byte Change all string functions that takes a length to use size_t instead of uint.
- Remove declarations of 'byte', 'my_string', 'size_s' and my_size_t from my_global.h - Replace usage of the above in all code with their correcpt type. This task should be done in a couple of stages Stage 1: - Convert all functions in dbug, strings, mysys, myisam, heap to use char * or uchar * depending on the context of the memory area. - Fix include files - Fix all function calls to these function - Remove all not needed casts. Stage 2: - Convert files in sql, libmysql, sql_common. Stage 3: - Convert files in other storage engines (not critical). - Convert any other files missing from the above lists.
Copyright (c) 2000, 2024, Oracle Corporation and/or its affiliates. All rights reserved.