summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
Diffstat (limited to 'mysys')
-rw-r--r--mysys/array.c18
-rw-r--r--mysys/charset.c20
-rw-r--r--mysys/checksum.c9
-rw-r--r--mysys/default.c23
-rw-r--r--mysys/default_modify.c13
-rw-r--r--mysys/hash.c65
-rw-r--r--mysys/list.c6
-rw-r--r--mysys/mf_cache.c2
-rw-r--r--mysys/mf_dirname.c28
-rw-r--r--mysys/mf_fn_ext.c11
-rw-r--r--mysys/mf_format.c36
-rw-r--r--mysys/mf_getdate.c2
-rw-r--r--mysys/mf_iocache.c253
-rw-r--r--mysys/mf_iocache2.c105
-rw-r--r--mysys/mf_keycache.c46
-rw-r--r--mysys/mf_keycaches.c44
-rw-r--r--mysys/mf_loadpath.c4
-rw-r--r--mysys/mf_pack.c184
-rw-r--r--mysys/mf_path.c12
-rw-r--r--mysys/mf_radix.c4
-rw-r--r--mysys/mf_same.c5
-rw-r--r--mysys/mf_sort.c8
-rw-r--r--mysys/mf_soundex.c4
-rw-r--r--mysys/mf_strip.c12
-rw-r--r--mysys/mf_tempdir.c2
-rw-r--r--mysys/mf_unixpath.c2
-rw-r--r--mysys/mf_wfile.c14
-rw-r--r--mysys/mulalloc.c6
-rw-r--r--mysys/my_alloc.c62
-rw-r--r--mysys/my_chsize.c8
-rw-r--r--mysys/my_compress.c160
-rw-r--r--mysys/my_conio.c12
-rw-r--r--mysys/my_create.c6
-rw-r--r--mysys/my_div.c2
-rw-r--r--mysys/my_error.c6
-rw-r--r--mysys/my_fopen.c4
-rw-r--r--mysys/my_fstream.c92
-rw-r--r--mysys/my_getopt.c18
-rw-r--r--mysys/my_getwd.c38
-rw-r--r--mysys/my_init.c2
-rw-r--r--mysys/my_largepage.c26
-rw-r--r--mysys/my_lib.c22
-rw-r--r--mysys/my_lockmem.c18
-rw-r--r--mysys/my_malloc.c38
-rw-r--r--mysys/my_memmem.c3
-rw-r--r--mysys/my_once.c26
-rw-r--r--mysys/my_open.c8
-rw-r--r--mysys/my_pread.c153
-rw-r--r--mysys/my_quick.c18
-rw-r--r--mysys/my_read.c25
-rw-r--r--mysys/my_realloc.c10
-rw-r--r--mysys/my_static.c6
-rw-r--r--mysys/my_static.h2
-rw-r--r--mysys/my_vle.c20
-rw-r--r--mysys/my_wincond.c2
-rw-r--r--mysys/my_windac.c8
-rw-r--r--mysys/my_write.c26
-rw-r--r--mysys/ptr_cmp.c26
-rw-r--r--mysys/queues.c36
-rw-r--r--mysys/safemalloc.c72
-rw-r--r--mysys/string.c40
-rw-r--r--mysys/testhash.c6
-rw-r--r--mysys/thr_alarm.c12
-rw-r--r--mysys/thr_lock.c4
-rw-r--r--mysys/tree.c8
-rw-r--r--mysys/trie.c8
-rw-r--r--mysys/typelib.c7
67 files changed, 991 insertions, 987 deletions
diff --git a/mysys/array.c b/mysys/array.c
index 60f5b255e18..123121ba096 100644
--- a/mysys/array.c
+++ b/mysys/array.c
@@ -77,9 +77,9 @@ my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size,
FALSE Ok
*/
-my_bool insert_dynamic(DYNAMIC_ARRAY *array, gptr element)
+my_bool insert_dynamic(DYNAMIC_ARRAY *array, uchar* element)
{
- gptr buffer;
+ uchar* buffer;
if (array->elements == array->max_element)
{ /* Call only when nessesary */
if (!(buffer=alloc_dynamic(array)))
@@ -112,7 +112,7 @@ my_bool insert_dynamic(DYNAMIC_ARRAY *array, gptr element)
0 Error
*/
-byte *alloc_dynamic(DYNAMIC_ARRAY *array)
+uchar *alloc_dynamic(DYNAMIC_ARRAY *array)
{
if (array->elements == array->max_element)
{
@@ -141,7 +141,7 @@ byte *alloc_dynamic(DYNAMIC_ARRAY *array)
0 Array is empty
*/
-byte *pop_dynamic(DYNAMIC_ARRAY *array)
+uchar *pop_dynamic(DYNAMIC_ARRAY *array)
{
if (array->elements)
return array->buffer+(--array->elements * array->size_of_element);
@@ -166,7 +166,7 @@ byte *pop_dynamic(DYNAMIC_ARRAY *array)
FALSE Ok
*/
-my_bool set_dynamic(DYNAMIC_ARRAY *array, gptr element, uint idx)
+my_bool set_dynamic(DYNAMIC_ARRAY *array, uchar* element, uint idx)
{
if (idx >= array->elements)
{
@@ -183,7 +183,7 @@ my_bool set_dynamic(DYNAMIC_ARRAY *array, gptr element, uint idx)
array->buffer=new_ptr;
array->max_element=size;
}
- bzero((gptr) (array->buffer+array->elements*array->size_of_element),
+ bzero((uchar*) (array->buffer+array->elements*array->size_of_element),
(idx - array->elements)*array->size_of_element);
array->elements=idx+1;
}
@@ -198,11 +198,11 @@ my_bool set_dynamic(DYNAMIC_ARRAY *array, gptr element, uint idx)
SYNOPSIS
get_dynamic()
array
- gptr Element to be returned. If idx > elements contain zeroes.
+ uchar* Element to be returned. If idx > elements contain zeroes.
idx Index of element wanted.
*/
-void get_dynamic(DYNAMIC_ARRAY *array, gptr element, uint idx)
+void get_dynamic(DYNAMIC_ARRAY *array, uchar* element, uint idx)
{
if (idx >= array->elements)
{
@@ -285,7 +285,7 @@ void freeze_size(DYNAMIC_ARRAY *array)
*/
-int get_index_dynamic(DYNAMIC_ARRAY *array, gptr element)
+int get_index_dynamic(DYNAMIC_ARRAY *array, uchar* element)
{
uint ret;
if (array->buffer > element)
diff --git a/mysys/charset.c b/mysys/charset.c
index cce97677b14..c6065f87df3 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -376,7 +376,7 @@ void add_compiled_collation(CHARSET_INFO *cs)
cs->state|= MY_CS_AVAILABLE;
}
-static void *cs_alloc(uint size)
+static void *cs_alloc(size_t size)
{
return my_once_alloc(size, MYF(MY_WME));
}
@@ -594,13 +594,13 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name,
"big enough"
RETURN VALUES
- ~0 The escaped string did not fit in the to buffer
- >=0 The length of the escaped string
+ (size_t) -1 The escaped string did not fit in the to buffer
+ # The length of the escaped string
*/
-ulong escape_string_for_mysql(CHARSET_INFO *charset_info,
- char *to, ulong to_length,
- const char *from, ulong length)
+size_t escape_string_for_mysql(CHARSET_INFO *charset_info,
+ char *to, size_t to_length,
+ const char *from, size_t length)
{
const char *to_start= to;
const char *end, *to_end=to_start + (to_length ? to_length-1 : 2*length);
@@ -684,7 +684,7 @@ ulong escape_string_for_mysql(CHARSET_INFO *charset_info,
}
}
*to= 0;
- return overflow ? (ulong)~0 : (ulong) (to - to_start);
+ return overflow ? (size_t) -1 : (size_t) (to - to_start);
}
@@ -738,9 +738,9 @@ CHARSET_INFO *fs_character_set()
>=0 The length of the escaped string
*/
-ulong escape_quotes_for_mysql(CHARSET_INFO *charset_info,
- char *to, ulong to_length,
- const char *from, ulong length)
+size_t escape_quotes_for_mysql(CHARSET_INFO *charset_info,
+ char *to, size_t to_length,
+ const char *from, size_t length)
{
const char *to_start= to;
const char *end, *to_end=to_start + (to_length ? to_length-1 : 2*length);
diff --git a/mysys/checksum.c b/mysys/checksum.c
index 09e9c5b3730..4f86f6845f0 100644
--- a/mysys/checksum.c
+++ b/mysys/checksum.c
@@ -15,7 +15,8 @@
#include <my_global.h>
-#include "my_sys.h"
+#include <my_sys.h>
+#include <zlib.h>
/*
Calculate a long checksum for a memoryblock.
@@ -27,15 +28,15 @@
length length of the block
*/
-ha_checksum my_checksum(ha_checksum crc, const byte *pos, uint length)
+ha_checksum my_checksum(ha_checksum crc, const uchar *pos, size_t length)
{
#ifdef NOT_USED
- const byte *end=pos+length;
+ const uchar *end=pos+length;
for ( ; pos != end ; pos++)
crc=((crc << 8) + *((uchar*) pos)) + (crc >> (8*sizeof(ha_checksum)-8));
return crc;
#else
- return (ha_checksum)crc32((uint)crc, (const uchar *)pos, length);
+ return (ha_checksum)crc32((uint)crc, pos, length);
#endif
}
diff --git a/mysys/default.c b/mysys/default.c
index 926a8f530bf..3cc5b08e77c 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -268,9 +268,9 @@ static int handle_default_option(void *in_ctx, const char *group_name,
if (find_type((char *)group_name, ctx->group, 3))
{
- if (!(tmp= alloc_root(ctx->alloc, (uint) strlen(option) + 1)))
+ if (!(tmp= alloc_root(ctx->alloc, strlen(option) + 1)))
return 1;
- if (insert_dynamic(ctx->args, (gptr) &tmp))
+ if (insert_dynamic(ctx->args, (uchar*) &tmp))
return 1;
strmov(tmp, option);
}
@@ -426,7 +426,7 @@ int load_defaults(const char *conf_file, const char **groups,
/* copy name + found arguments + command line arguments to new array */
res[0]= argv[0][0]; /* Name MUST be set, even by embedded library */
- memcpy((gptr) (res+1), args.buffer, args.elements*sizeof(char*));
+ memcpy((uchar*) (res+1), args.buffer, args.elements*sizeof(char*));
/* Skip --defaults-xxx options */
(*argc)-= args_used;
(*argv)+= args_used;
@@ -442,7 +442,7 @@ int load_defaults(const char *conf_file, const char **groups,
}
if (*argc)
- memcpy((gptr) (res+1+args.elements), (char*) ((*argv)+1),
+ memcpy((uchar*) (res+1+args.elements), (char*) ((*argv)+1),
(*argc-1)*sizeof(char*));
res[args.elements+ *argc]=0; /* last null */
@@ -514,7 +514,7 @@ static int search_default_file(Process_option_func opt_handler,
# Returns pointer to the argument after the keyword.
*/
-static char *get_argument(const char *keyword, uint kwlen,
+static char *get_argument(const char *keyword, size_t kwlen,
char *ptr, char *name, uint line)
{
char *end;
@@ -718,10 +718,11 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
name,line);
goto err;
}
- for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;/* Remove end space */
+ /* Remove end space */
+ for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
end[0]=0;
- strnmov(curr_gr, ptr, min((uint) (end-ptr)+1, 4096));
+ strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
/* signal that a new group is found */
opt_handler(handler_ctx, curr_gr, NULL);
@@ -743,7 +744,7 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
if (!value)
{
- strmake(strmov(option,"--"),ptr,(uint) (end-ptr));
+ strmake(strmov(option,"--"),ptr, (size_t) (end-ptr));
if (opt_handler(handler_ctx, curr_gr, option))
goto err;
}
@@ -769,7 +770,7 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
value++;
value_end--;
}
- ptr=strnmov(strmov(option,"--"),ptr,(uint) (end-ptr));
+ ptr=strnmov(strmov(option,"--"),ptr,(size_t) (end-ptr));
*ptr++= '=';
for ( ; value != value_end; value++)
@@ -931,9 +932,9 @@ void print_defaults(const char *conf_file, const char **groups)
typedef UINT (WINAPI *GET_SYSTEM_WINDOWS_DIRECTORY)(LPSTR, UINT);
-static uint my_get_system_windows_directory(char *buffer, uint size)
+static size_t my_get_system_windows_directory(char *buffer, size_t size)
{
- uint count;
+ size_t count;
GET_SYSTEM_WINDOWS_DIRECTORY
func_ptr= (GET_SYSTEM_WINDOWS_DIRECTORY)
GetProcAddress(GetModuleHandle("kernel32.dll"),
diff --git a/mysys/default_modify.c b/mysys/default_modify.c
index f58d3e0da86..b2a43f511b9 100644
--- a/mysys/default_modify.c
+++ b/mysys/default_modify.c
@@ -68,9 +68,8 @@ int modify_defaults_file(const char *file_location, const char *option,
FILE *cnf_file;
MY_STAT file_stat;
char linebuff[BUFF_SIZE], *src_ptr, *dst_ptr, *file_buffer;
- uint opt_len= 0;
- uint optval_len= 0;
- uint sect_len, nr_newlines= 0, buffer_size;
+ size_t opt_len= 0, optval_len= 0, sect_len;
+ uint nr_newlines= 0, buffer_size;
my_bool in_section= FALSE, opt_applied= 0;
uint reserve_extended;
uint new_opt_len;
@@ -86,8 +85,8 @@ int modify_defaults_file(const char *file_location, const char *option,
if (option && option_value)
{
- opt_len= (uint) strlen(option);
- optval_len= (uint) strlen(option_value);
+ opt_len= strlen(option);
+ optval_len= strlen(option_value);
}
new_opt_len= opt_len + 1 + optval_len + NEWLINE_LEN;
@@ -110,7 +109,7 @@ int modify_defaults_file(const char *file_location, const char *option,
MYF(MY_WME))))
goto malloc_err;
- sect_len= (uint) strlen(section_name);
+ sect_len= strlen(section_name);
for (dst_ptr= file_buffer; fgets(linebuff, BUFF_SIZE, cnf_file); )
{
@@ -219,7 +218,7 @@ int modify_defaults_file(const char *file_location, const char *option,
if (my_chsize(fileno(cnf_file), (my_off_t) (dst_ptr - file_buffer), 0,
MYF(MY_WME)) ||
my_fseek(cnf_file, 0, MY_SEEK_SET, MYF(0)) ||
- my_fwrite(cnf_file, file_buffer, (uint) (dst_ptr - file_buffer),
+ my_fwrite(cnf_file, file_buffer, (size_t) (dst_ptr - file_buffer),
MYF(MY_NABP)))
goto err;
}
diff --git a/mysys/hash.c b/mysys/hash.c
index 60168e01e20..275e9d8d9c4 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -30,15 +30,15 @@
typedef struct st_hash_info {
uint next; /* index to next key */
- byte *data; /* data for current entry */
+ uchar *data; /* data for current entry */
} HASH_LINK;
static uint hash_mask(uint hashnr,uint buffmax,uint maxlength);
static void movelink(HASH_LINK *array,uint pos,uint next_link,uint newlink);
-static int hashcmp(const HASH *hash, HASH_LINK *pos, const byte *key,
- uint length);
+static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key,
+ size_t length);
-static uint calc_hash(const HASH *hash, const byte *key, uint length)
+static uint calc_hash(const HASH *hash, const uchar *key, size_t length)
{
ulong nr1=1, nr2=4;
hash->charset->coll->hash_sort(hash->charset,(uchar*) key,length,&nr1,&nr2);
@@ -47,12 +47,12 @@ static uint calc_hash(const HASH *hash, const byte *key, uint length)
my_bool
_hash_init(HASH *hash,CHARSET_INFO *charset,
- uint size,uint key_offset,uint key_length,
+ ulong size, size_t key_offset, size_t key_length,
hash_get_key get_key,
void (*free_element)(void*),uint flags CALLER_INFO_PROTO)
{
DBUG_ENTER("hash_init");
- DBUG_PRINT("enter",("hash: 0x%lx size: %d", (long) hash, size));
+ 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,0))
@@ -140,18 +140,18 @@ void my_hash_reset(HASH *hash)
/* some helper functions */
/*
- This function is char* instead of byte* as HPUX11 compiler can't
+ This function is char* instead of uchar* as HPUX11 compiler can't
handle inline functions that are not defined as native types
*/
static inline char*
-hash_key(const HASH *hash, const byte *record, uint *length,
+hash_key(const HASH *hash, const uchar *record, size_t *length,
my_bool first)
{
if (hash->get_key)
return (*hash->get_key)(record,length,first);
*length=hash->key_length;
- return (byte*) record+hash->key_offset;
+ return (uchar*) record+hash->key_offset;
}
/* Calculate pos according to keys */
@@ -165,8 +165,8 @@ static uint hash_mask(uint hashnr,uint buffmax,uint maxlength)
static uint hash_rec_mask(const HASH *hash, HASH_LINK *pos,
uint buffmax, uint maxlength)
{
- uint length;
- byte *key= (byte*) hash_key(hash,pos->data,&length,0);
+ size_t length;
+ uchar *key= (uchar*) hash_key(hash,pos->data,&length,0);
return hash_mask(calc_hash(hash,key,length),buffmax,maxlength);
}
@@ -177,15 +177,15 @@ static
#if !defined(__USLC__) && !defined(__sgi)
inline
#endif
-unsigned int rec_hashnr(HASH *hash,const byte *record)
+unsigned int rec_hashnr(HASH *hash,const uchar *record)
{
- uint length;
- byte *key= (byte*) hash_key(hash,record,&length,0);
+ size_t length;
+ uchar *key= (uchar*) hash_key(hash,record,&length,0);
return calc_hash(hash,key,length);
}
-gptr hash_search(const HASH *hash, const byte *key, uint length)
+uchar* hash_search(const HASH *hash, const uchar *key, size_t length)
{
HASH_SEARCH_STATE state;
return hash_first(hash, key, length, &state);
@@ -198,7 +198,7 @@ gptr hash_search(const HASH *hash, const byte *key, uint length)
Assigns the number of the found record to HASH_SEARCH_STATE state
*/
-gptr hash_first(const HASH *hash, const byte *key, uint length,
+uchar* hash_first(const HASH *hash, const uchar *key, size_t length,
HASH_SEARCH_STATE *current_record)
{
HASH_LINK *pos;
@@ -235,7 +235,7 @@ gptr hash_first(const HASH *hash, const byte *key, uint length,
/* Get next record with identical key */
/* Can only be called if previous calls was hash_search */
-gptr hash_next(const HASH *hash, const byte *key, uint length,
+uchar* hash_next(const HASH *hash, const uchar *key, size_t length,
HASH_SEARCH_STATE *current_record)
{
HASH_LINK *pos;
@@ -292,11 +292,11 @@ static void movelink(HASH_LINK *array,uint find,uint next_link,uint newlink)
!= 0 key of record != key
*/
-static int hashcmp(const HASH *hash, HASH_LINK *pos, const byte *key,
- uint length)
+static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key,
+ size_t length)
{
- uint rec_keylength;
- byte *rec_key= (byte*) hash_key(hash,pos->data,&rec_keylength,1);
+ size_t rec_keylength;
+ uchar *rec_key= (uchar*) hash_key(hash,pos->data,&rec_keylength,1);
return ((length && length != rec_keylength) ||
my_strnncoll(hash->charset, (uchar*) rec_key, rec_keylength,
(uchar*) key, rec_keylength));
@@ -305,11 +305,11 @@ static int hashcmp(const HASH *hash, HASH_LINK *pos, const byte *key,
/* Write a hash-key to the hash-index */
-my_bool my_hash_insert(HASH *info,const byte *record)
+my_bool my_hash_insert(HASH *info,const uchar *record)
{
int flag;
uint halfbuff,hash_nr,first_index,idx;
- byte *ptr_to_rec,*ptr_to_rec2;
+ uchar *ptr_to_rec,*ptr_to_rec2;
HASH_LINK *data,*empty,*gpos,*gpos2,*pos;
LINT_INIT(gpos); LINT_INIT(gpos2);
@@ -357,7 +357,7 @@ my_bool my_hash_insert(HASH *info,const byte *record)
{
/* Change link of previous LOW-key */
gpos->data=ptr_to_rec;
- gpos->next=(uint) (pos-data);
+ gpos->next= (uint) (pos-data);
flag= (flag & HIGHFIND) | (LOWFIND | LOWUSED);
}
gpos=pos;
@@ -406,7 +406,7 @@ my_bool my_hash_insert(HASH *info,const byte *record)
pos=data+idx;
if (pos == empty)
{
- pos->data=(byte*) record;
+ pos->data=(uchar*) record;
pos->next=NO_RECORD;
}
else
@@ -416,12 +416,12 @@ my_bool my_hash_insert(HASH *info,const byte *record)
gpos=data+hash_rec_mask(info,pos,info->blength,info->records+1);
if (pos == gpos)
{
- pos->data=(byte*) record;
+ pos->data=(uchar*) record;
pos->next=(uint) (empty - data);
}
else
{
- pos->data=(byte*) record;
+ pos->data=(uchar*) record;
pos->next=NO_RECORD;
movelink(data,(uint) (pos-data),(uint) (gpos-data),(uint) (empty-data));
}
@@ -438,7 +438,7 @@ my_bool my_hash_insert(HASH *info,const byte *record)
** if there is a free-function it's called for record if found
******************************************************************************/
-my_bool hash_delete(HASH *hash,byte *record)
+my_bool hash_delete(HASH *hash,uchar *record)
{
uint blength,pos2,pos_hashnr,lastpos_hashnr,idx,empty_index;
HASH_LINK *data,*lastpos,*gpos,*pos,*pos3,*empty;
@@ -516,7 +516,7 @@ my_bool hash_delete(HASH *hash,byte *record)
exit:
VOID(pop_dynamic(&hash->array));
if (hash->free)
- (*hash->free)((byte*) record);
+ (*hash->free)((uchar*) record);
DBUG_RETURN(0);
}
@@ -525,7 +525,8 @@ exit:
This is much more efficent than using a delete & insert.
*/
-my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length)
+my_bool hash_update(HASH *hash, uchar *record, uchar *old_key,
+ size_t old_key_length)
{
uint idx,new_index,new_pos_index,blength,records,empty;
HASH_LINK org_link,*data,*previous,*pos;
@@ -589,7 +590,7 @@ my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length)
}
-byte *hash_element(HASH *hash,uint idx)
+uchar *hash_element(HASH *hash,ulong idx)
{
if (idx < hash->records)
return dynamic_element(&hash->array,idx,HASH_LINK*)->data;
@@ -602,7 +603,7 @@ byte *hash_element(HASH *hash,uint idx)
isn't changed
*/
-void hash_replace(HASH *hash, HASH_SEARCH_STATE *current_record, byte *new_row)
+void hash_replace(HASH *hash, HASH_SEARCH_STATE *current_record, uchar *new_row)
{
if (*current_record != NO_RECORD) /* Safety */
dynamic_element(&hash->array, *current_record, HASH_LINK*)->data= new_row;
diff --git a/mysys/list.c b/mysys/list.c
index ccc3f495093..aaadd686365 100644
--- a/mysys/list.c
+++ b/mysys/list.c
@@ -61,8 +61,8 @@ void list_free(LIST *root, uint free_data)
{
next=root->next;
if (free_data)
- my_free((gptr) root->data,MYF(0));
- my_free((gptr) root,MYF(0));
+ my_free((uchar*) root->data,MYF(0));
+ my_free((uchar*) root,MYF(0));
root=next;
}
}
@@ -101,7 +101,7 @@ uint list_length(LIST *list)
}
-int list_walk(LIST *list, list_walk_action action, gptr argument)
+int list_walk(LIST *list, list_walk_action action, uchar* argument)
{
int error=0;
while (list)
diff --git a/mysys/mf_cache.c b/mysys/mf_cache.c
index a3abb3bc974..f0df0f3fa77 100644
--- a/mysys/mf_cache.c
+++ b/mysys/mf_cache.c
@@ -58,7 +58,7 @@ static my_bool cache_remove_open_tmp(IO_CACHE *cache __attribute__((unused)),
*/
my_bool open_cached_file(IO_CACHE *cache, const char* dir, const char *prefix,
- uint cache_size, myf cache_myflags)
+ size_t cache_size, myf cache_myflags)
{
DBUG_ENTER("open_cached_file");
cache->dir= dir ? my_strdup(dir,MYF(cache_myflags & MY_WME)) : (char*) 0;
diff --git a/mysys/mf_dirname.c b/mysys/mf_dirname.c
index 87a4a453734..1b428ded751 100644
--- a/mysys/mf_dirname.c
+++ b/mysys/mf_dirname.c
@@ -18,9 +18,9 @@
/* Functions definied in this file */
-uint dirname_length(const char *name)
+size_t dirname_length(const char *name)
{
- register my_string pos,gpos;
+ register char *pos, *gpos;
#ifdef BASKSLASH_MBTAIL
CHARSET_INFO *fs= fs_character_set();
#endif
@@ -47,21 +47,31 @@ uint dirname_length(const char *name)
)
gpos=pos;
}
- return ((uint) (uint) (gpos+1-(char*) name));
+ return (size_t) (gpos+1-(char*) name);
}
- /* Gives directory part of filename. Directory ends with '/' */
- /* Returns length of directory part */
+/*
+ Gives directory part of filename. Directory ends with '/'
+
+ SYNOPSIS
+ dirname_part()
+ to Store directory name here
+ name Original name
+ to_length Store length of 'to' here
+
+ RETURN
+ # Length of directory part in 'name'
+*/
-uint dirname_part(my_string to, const char *name)
+size_t dirname_part(char *to, const char *name, size_t *to_res_length)
{
- uint length;
+ size_t length;
DBUG_ENTER("dirname_part");
DBUG_PRINT("enter",("'%s'",name));
length=dirname_length(name);
- convert_dirname(to, name, name+length);
+ *to_res_length= (size_t) (convert_dirname(to, name, name+length) - to);
DBUG_RETURN(length);
} /* dirname */
@@ -142,7 +152,7 @@ char *convert_dirname(char *to, const char *from, const char *from_end)
}
#else
/* This is ok even if to == from, becasue we need to cut the string */
- to= strmake(to, from, (uint) (from_end-from));
+ to= strmake(to, from, (size_t) (from_end-from));
#endif
/* Add FN_LIBCHAR to the end of directory path */
diff --git a/mysys/mf_fn_ext.c b/mysys/mf_fn_ext.c
index 20e835fe641..da7fac3de73 100644
--- a/mysys/mf_fn_ext.c
+++ b/mysys/mf_fn_ext.c
@@ -33,21 +33,22 @@
points at the end ASCII(0) of the filename.
*/
-my_string fn_ext(const char *name)
+char *fn_ext(const char *name)
{
- register my_string pos,gpos;
+ register const char *pos, *gpos;
DBUG_ENTER("fn_ext");
DBUG_PRINT("mfunkt",("name: '%s'",name));
#if defined(FN_DEVCHAR) || defined(FN_C_AFTER_DIR) || defined(BASKSLASH_MBTAIL)
{
char buff[FN_REFLEN];
- gpos=(my_string) name+dirname_part(buff,(char*) name);
+ size_t res_length;
+ gpos= name+ dirname_part(buff,(char*) name, &res_length);
}
#else
if (!(gpos= strrchr(name, FN_LIBCHAR)))
- gpos= (my_string) name;
+ gpos= name;
#endif
pos=strchr(gpos,FN_EXTCHAR);
- DBUG_RETURN (pos ? pos : strend(gpos));
+ DBUG_RETURN((char*) (pos ? pos : strend(gpos)));
} /* fn_ext */
diff --git a/mysys/mf_format.c b/mysys/mf_format.c
index 3e5eeef6420..f199132626b 100644
--- a/mysys/mf_format.c
+++ b/mysys/mf_format.c
@@ -23,18 +23,19 @@
The arguments should be in unix format.
*/
-my_string fn_format(my_string to, const char *name, const char *dir,
+char * fn_format(char * to, const char *name, const char *dir,
const char *extension, uint flag)
{
- reg1 uint length;
char dev[FN_REFLEN], buff[FN_REFLEN], *pos, *startpos;
const char *ext;
+ reg1 size_t length;
+ size_t dev_length;
DBUG_ENTER("fn_format");
DBUG_PRINT("enter",("name: %s dir: %s extension: %s flag: %d",
name,dir,extension,flag));
/* Copy and skip directory */
- name+=(length=dirname_part(dev,(startpos=(my_string) name)));
+ name+=(length=dirname_part(dev, (startpos=(char *) name), &dev_length));
if (length == 0 || (flag & MY_REPLACE_DIR))
{
/* Use given directory */
@@ -63,7 +64,7 @@ my_string fn_format(my_string to, const char *name, const char *dir,
}
else
{
- length=(uint) (pos-(char*) name); /* Change extension */
+ length= (size_t) (pos-(char*) name); /* Change extension */
ext= extension;
}
}
@@ -76,18 +77,19 @@ my_string fn_format(my_string to, const char *name, const char *dir,
if (strlen(dev)+length+strlen(ext) >= FN_REFLEN || length >= FN_LEN )
{
/* To long path, return original or NULL */
- uint tmp_length;
+ size_t tmp_length;
if (flag & MY_SAFE_PATH)
return NullS;
- tmp_length=strlength(startpos);
- DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %d",dev,ext,length));
+ tmp_length= strlength(startpos);
+ DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext,
+ (uint) length));
(void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
}
else
{
if (to == startpos)
{
- bmove(buff,(char*) name,length); /* Save name for last copy */
+ bmove(buff,(uchar*) name,length); /* Save name for last copy */
name=buff;
}
pos=strmake(strmov(to,dev),name,length);
@@ -109,18 +111,18 @@ my_string fn_format(my_string to, const char *name, const char *dir,
} /* fn_format */
- /*
- strlength(const string str)
- Return length of string with end-space:s not counted.
- */
+/*
+ strlength(const string str)
+ Return length of string with end-space:s not counted.
+*/
-size_s strlength(const char *str)
+size_t strlength(const char *str)
{
- reg1 my_string pos;
- reg2 my_string found;
+ reg1 const char * pos;
+ reg2 const char * found;
DBUG_ENTER("strlength");
- pos=found=(char*) str;
+ pos= found= str;
while (*pos)
{
@@ -136,5 +138,5 @@ size_s strlength(const char *str)
found=pos;
while (*++pos == ' ') {};
}
- DBUG_RETURN((size_s) (found-(char*) str));
+ DBUG_RETURN((size_t) (found - str));
} /* strlength */
diff --git a/mysys/mf_getdate.c b/mysys/mf_getdate.c
index 1ced312848e..2f08027a477 100644
--- a/mysys/mf_getdate.c
+++ b/mysys/mf_getdate.c
@@ -34,7 +34,7 @@
*/
-void get_date(register my_string to, int flag, time_t date)
+void get_date(register char * to, int flag, time_t date)
{
reg2 struct tm *start_time;
time_t skr;
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c
index d2ace12da4d..58650733490 100644
--- a/mysys/mf_iocache.c
+++ b/mysys/mf_iocache.c
@@ -152,11 +152,11 @@ init_functions(IO_CACHE* info)
# error
*/
-int init_io_cache(IO_CACHE *info, File file, uint cachesize,
+int init_io_cache(IO_CACHE *info, File file, size_t cachesize,
enum cache_type type, my_off_t seek_offset,
pbool use_async_io, myf cache_myflags)
{
- uint min_cache;
+ size_t min_cache;
my_off_t pos;
my_off_t end_of_file= ~(my_off_t) 0;
DBUG_ENTER("init_io_cache");
@@ -214,7 +214,7 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize,
/* Trim cache size if the file is very small */
if ((my_off_t) cachesize > end_of_file-seek_offset+IO_SIZE*2-1)
{
- cachesize=(uint) (end_of_file-seek_offset)+IO_SIZE*2-1;
+ cachesize= (size_t) (end_of_file-seek_offset)+IO_SIZE*2-1;
use_async_io=0; /* No need to use async */
}
}
@@ -223,18 +223,17 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize,
if (type != READ_NET && type != WRITE_NET)
{
/* Retry allocating memory in smaller blocks until we get one */
- cachesize=(uint) ((ulong) (cachesize + min_cache-1) &
- (ulong) ~(min_cache-1));
+ cachesize= ((cachesize + min_cache-1) & ~(min_cache-1));
for (;;)
{
- uint buffer_block;
+ size_t buffer_block;
if (cachesize < min_cache)
cachesize = min_cache;
- buffer_block = cachesize;
+ buffer_block= cachesize;
if (type == SEQ_READ_APPEND)
buffer_block *= 2;
if ((info->buffer=
- (byte*) my_malloc(buffer_block,
+ (uchar*) my_malloc(buffer_block,
MYF((cache_myflags & ~ MY_WME) |
(cachesize == min_cache ? MY_WME : 0)))) != 0)
{
@@ -247,11 +246,11 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize,
if (cachesize == min_cache)
DBUG_RETURN(2); /* Can't alloc cache */
/* Try with less memory */
- cachesize= (uint) ((ulong) cachesize*3/4 & (ulong)~(min_cache-1));
+ cachesize= (cachesize*3/4 & ~(min_cache-1));
}
}
- DBUG_PRINT("info",("init_io_cache: cachesize = %u",cachesize));
+ DBUG_PRINT("info",("init_io_cache: cachesize = %lu", (ulong) cachesize));
info->read_length=info->buffer_length=cachesize;
info->myflags=cache_myflags & ~(MY_NABP | MY_FNABP);
info->request_pos= info->read_pos= info->write_pos = info->buffer;
@@ -350,7 +349,7 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
seek_offset <= my_b_tell(info))
{
/* Reuse current buffer without flushing it to disk */
- byte *pos;
+ uchar *pos;
if (info->type == WRITE_CACHE && type == READ_CACHE)
{
info->read_end=info->write_pos;
@@ -452,22 +451,22 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
1 Error: can't read requested characters
*/
-int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count)
+int _my_b_read(register IO_CACHE *info, uchar *Buffer, size_t Count)
{
- uint length,diff_length,left_length;
- my_off_t max_length, pos_in_file;
+ size_t length,diff_length,left_length, max_length;
+ my_off_t pos_in_file;
DBUG_ENTER("_my_b_read");
- if ((left_length=(uint) (info->read_end-info->read_pos)))
+ if ((left_length= (size_t) (info->read_end-info->read_pos)))
{
DBUG_ASSERT(Count >= left_length); /* User is not using my_b_read() */
- memcpy(Buffer,info->read_pos, (size_t) (left_length));
+ memcpy(Buffer,info->read_pos, left_length);
Buffer+=left_length;
Count-=left_length;
}
/* pos_in_file always point on where info->buffer was read */
- pos_in_file=info->pos_in_file+(uint) (info->read_end - info->buffer);
+ pos_in_file=info->pos_in_file+ (size_t) (info->read_end - info->buffer);
/*
Whenever a function which operates on IO_CACHE flushes/writes
@@ -496,20 +495,20 @@ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count)
}
}
- diff_length=(uint) (pos_in_file & (IO_SIZE-1));
- if (Count >= (uint) (IO_SIZE+(IO_SIZE-diff_length)))
+ diff_length= (size_t) (pos_in_file & (IO_SIZE-1));
+ if (Count >= (size_t) (IO_SIZE+(IO_SIZE-diff_length)))
{ /* Fill first intern buffer */
- uint read_length;
+ size_t read_length;
if (info->end_of_file <= pos_in_file)
{ /* End of file */
- info->error=(int) left_length;
+ info->error= (int) left_length;
DBUG_RETURN(1);
}
- length=(Count & (uint) ~(IO_SIZE-1))-diff_length;
- if ((read_length=my_read(info->file,Buffer,(uint) length,info->myflags))
- != (uint) length)
+ length=(Count & (size_t) ~(IO_SIZE-1))-diff_length;
+ if ((read_length= my_read(info->file,Buffer, length, info->myflags))
+ != length)
{
- info->error= (read_length == (uint) -1 ? -1 :
+ info->error= (read_length == (size_t) -1 ? -1 :
(int) (read_length+left_length));
DBUG_RETURN(1);
}
@@ -520,10 +519,10 @@ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count)
diff_length=0;
}
- max_length=info->read_length-diff_length;
+ max_length= info->read_length-diff_length;
if (info->type != READ_FIFO &&
max_length > (info->end_of_file - pos_in_file))
- max_length = info->end_of_file - pos_in_file;
+ max_length= (size_t) (info->end_of_file - pos_in_file);
if (!max_length)
{
if (Count)
@@ -533,21 +532,21 @@ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count)
}
length=0; /* Didn't read any chars */
}
- else if ((length=my_read(info->file,info->buffer,(uint) max_length,
- info->myflags)) < Count ||
- length == (uint) -1)
+ else if ((length= my_read(info->file,info->buffer, max_length,
+ info->myflags)) < Count ||
+ length == (size_t) -1)
{
- if (length != (uint) -1)
- memcpy(Buffer,info->buffer,(size_t) length);
+ if (length != (size_t) -1)
+ memcpy(Buffer, info->buffer, length);
info->pos_in_file= pos_in_file;
- info->error= length == (uint) -1 ? -1 : (int) (length+left_length);
+ info->error= length == (size_t) -1 ? -1 : (int) (length+left_length);
info->read_pos=info->read_end=info->buffer;
DBUG_RETURN(1);
}
info->read_pos=info->buffer+Count;
info->read_end=info->buffer+length;
info->pos_in_file=pos_in_file;
- memcpy(Buffer,info->buffer,(size_t) Count);
+ memcpy(Buffer, info->buffer, Count);
DBUG_RETURN(0);
}
@@ -859,8 +858,9 @@ static int lock_io_cache(IO_CACHE *cache, my_off_t pos)
/* Another thread did read the block already. */
}
DBUG_PRINT("io_cache_share", ("reader awoke, going to process %u bytes",
- cshare->read_end ? (uint)
- (cshare->read_end - cshare->buffer) : 0));
+ (uint) (cshare->read_end ? (size_t)
+ (cshare->read_end - cshare->buffer) :
+ 0)));
/*
Leave the lock. Do not call unlock_io_cache() later. The thread that
@@ -952,33 +952,33 @@ static void unlock_io_cache(IO_CACHE *cache)
1 Error: can't read requested characters
*/
-int _my_b_read_r(register IO_CACHE *cache, byte *Buffer, uint Count)
+int _my_b_read_r(register IO_CACHE *cache, uchar *Buffer, size_t Count)
{
my_off_t pos_in_file;
- uint length, diff_length, left_length;
+ size_t length, diff_length, left_length;
IO_CACHE_SHARE *cshare= cache->share;
DBUG_ENTER("_my_b_read_r");
- if ((left_length= (uint) (cache->read_end - cache->read_pos)))
+ if ((left_length= (size_t) (cache->read_end - cache->read_pos)))
{
DBUG_ASSERT(Count >= left_length); /* User is not using my_b_read() */
- memcpy(Buffer, cache->read_pos, (size_t) (left_length));
+ memcpy(Buffer, cache->read_pos, left_length);
Buffer+= left_length;
Count-= left_length;
}
while (Count)
{
- int cnt, len;
+ size_t cnt, len;
pos_in_file= cache->pos_in_file + (cache->read_end - cache->buffer);
- diff_length= (uint) (pos_in_file & (IO_SIZE-1));
+ diff_length= (size_t) (pos_in_file & (IO_SIZE-1));
length=IO_ROUND_UP(Count+diff_length)-diff_length;
length= ((length <= cache->read_length) ?
length + IO_ROUND_DN(cache->read_length - length) :
length - IO_ROUND_UP(length - cache->read_length));
if (cache->type != READ_FIFO &&
(length > (cache->end_of_file - pos_in_file)))
- length= (uint) (cache->end_of_file - pos_in_file);
+ length= (size_t) (cache->end_of_file - pos_in_file);
if (length == 0)
{
cache->error= (int) left_length;
@@ -1013,12 +1013,12 @@ int _my_b_read_r(register IO_CACHE *cache, byte *Buffer, uint Count)
DBUG_RETURN(1);
}
}
- len= (int) my_read(cache->file, cache->buffer, length, cache->myflags);
+ len= my_read(cache->file, cache->buffer, length, cache->myflags);
}
- DBUG_PRINT("io_cache_share", ("read %d bytes", len));
+ DBUG_PRINT("io_cache_share", ("read %lu bytes", (ulong) len));
- cache->read_end= cache->buffer + (len == -1 ? 0 : len);
- cache->error= (len == (int)length ? 0 : len);
+ cache->read_end= cache->buffer + (len == (size_t) -1 ? 0 : len);
+ cache->error= (len == length ? 0 : (int) len);
cache->pos_in_file= pos_in_file;
/* Copy important values to the share. */
@@ -1039,19 +1039,20 @@ int _my_b_read_r(register IO_CACHE *cache, byte *Buffer, uint Count)
cache->read_end= cshare->read_end;
cache->pos_in_file= cshare->pos_in_file;
- len= (int) ((cache->error == -1) ? -1 : cache->read_end - cache->buffer);
+ len= ((cache->error == -1) ? (size_t) -1 :
+ (size_t) (cache->read_end - cache->buffer));
}
cache->read_pos= cache->buffer;
cache->seek_not_done= 0;
- if (len <= 0)
+ if (len == 0 || len == (size_t) -1)
{
- DBUG_PRINT("io_cache_share", ("reader error. len %d left %u",
- len, left_length));
+ DBUG_PRINT("io_cache_share", ("reader error. len %lu left %lu",
+ (ulong) len, (ulong) left_length));
cache->error= (int) left_length;
DBUG_RETURN(1);
}
- cnt= ((uint) len > Count) ? (int) Count : len;
- memcpy(Buffer, cache->read_pos, (size_t) cnt);
+ cnt= (len > Count) ? Count : len;
+ memcpy(Buffer, cache->read_pos, cnt);
Count -= cnt;
Buffer+= cnt;
left_length+= cnt;
@@ -1079,7 +1080,7 @@ int _my_b_read_r(register IO_CACHE *cache, byte *Buffer, uint Count)
*/
static void copy_to_read_buffer(IO_CACHE *write_cache,
- const byte *write_buffer, uint write_length)
+ const uchar *write_buffer, size_t write_length)
{
IO_CACHE_SHARE *cshare= write_cache->share;
@@ -1090,7 +1091,7 @@ static void copy_to_read_buffer(IO_CACHE *write_cache,
*/
while (write_length)
{
- uint copy_length= min(write_length, write_cache->buffer_length);
+ size_t copy_length= min(write_length, write_cache->buffer_length);
int __attribute__((unused)) rc;
rc= lock_io_cache(write_cache, write_cache->pos_in_file);
@@ -1126,33 +1127,32 @@ static void copy_to_read_buffer(IO_CACHE *write_cache,
1 Failed to read
*/
-int _my_b_seq_read(register IO_CACHE *info, byte *Buffer, uint Count)
+int _my_b_seq_read(register IO_CACHE *info, uchar *Buffer, size_t Count)
{
- uint length,diff_length,left_length,save_count;
- my_off_t max_length, pos_in_file;
+ size_t length, diff_length, left_length, save_count, max_length;
+ my_off_t pos_in_file;
save_count=Count;
/* first, read the regular buffer */
- if ((left_length=(uint) (info->read_end-info->read_pos)))
+ if ((left_length=(size_t) (info->read_end-info->read_pos)))
{
DBUG_ASSERT(Count > left_length); /* User is not using my_b_read() */
- memcpy(Buffer,info->read_pos, (size_t) (left_length));
+ memcpy(Buffer,info->read_pos, left_length);
Buffer+=left_length;
Count-=left_length;
}
lock_append_buffer(info);
/* pos_in_file always point on where info->buffer was read */
- if ((pos_in_file=info->pos_in_file+(uint) (info->read_end - info->buffer)) >=
- info->end_of_file)
+ if ((pos_in_file=info->pos_in_file +
+ (size_t) (info->read_end - info->buffer)) >= info->end_of_file)
goto read_append_buffer;
/*
With read-append cache we must always do a seek before we read,
because the write could have moved the file pointer astray
*/
- if (my_seek(info->file,pos_in_file,MY_SEEK_SET,MYF(0))
- == MY_FILEPOS_ERROR)
+ if (my_seek(info->file,pos_in_file,MY_SEEK_SET,MYF(0)) == MY_FILEPOS_ERROR)
{
info->error= -1;
unlock_append_buffer(info);
@@ -1160,16 +1160,17 @@ int _my_b_seq_read(register IO_CACHE *info, byte *Buffer, uint Count)
}
info->seek_not_done=0;
- diff_length=(uint) (pos_in_file & (IO_SIZE-1));
+ diff_length= (size_t) (pos_in_file & (IO_SIZE-1));
/* now the second stage begins - read from file descriptor */
- if (Count >= (uint) (IO_SIZE+(IO_SIZE-diff_length)))
- { /* Fill first intern buffer */
- uint read_length;
+ if (Count >= (size_t) (IO_SIZE+(IO_SIZE-diff_length)))
+ {
+ /* Fill first intern buffer */
+ size_t read_length;
- length=(Count & (uint) ~(IO_SIZE-1))-diff_length;
- if ((read_length=my_read(info->file,Buffer,(uint) length,info->myflags)) ==
- (uint)-1)
+ length=(Count & (size_t) ~(IO_SIZE-1))-diff_length;
+ if ((read_length= my_read(info->file,Buffer, length,
+ info->myflags)) == (size_t) -1)
{
info->error= -1;
unlock_append_buffer(info);
@@ -1179,7 +1180,7 @@ int _my_b_seq_read(register IO_CACHE *info, byte *Buffer, uint Count)
Buffer+=read_length;
pos_in_file+=read_length;
- if (read_length != (uint) length)
+ if (read_length != length)
{
/*
We only got part of data; Read the rest of the data from the
@@ -1191,9 +1192,9 @@ int _my_b_seq_read(register IO_CACHE *info, byte *Buffer, uint Count)
diff_length=0;
}
- max_length=info->read_length-diff_length;
+ max_length= info->read_length-diff_length;
if (max_length > (info->end_of_file - pos_in_file))
- max_length = info->end_of_file - pos_in_file;
+ max_length= (size_t) (info->end_of_file - pos_in_file);
if (!max_length)
{
if (Count)
@@ -1202,9 +1203,8 @@ int _my_b_seq_read(register IO_CACHE *info, byte *Buffer, uint Count)
}
else
{
- length=my_read(info->file,info->buffer,(uint) max_length,
- info->myflags);
- if (length == (uint) -1)
+ length= my_read(info->file,info->buffer, max_length, info->myflags);
+ if (length == (size_t) -1)
{
info->error= -1;
unlock_append_buffer(info);
@@ -1212,7 +1212,7 @@ int _my_b_seq_read(register IO_CACHE *info, byte *Buffer, uint Count)
}
if (length < Count)
{
- memcpy(Buffer,info->buffer,(size_t) length);
+ memcpy(Buffer, info->buffer, length);
Count -= length;
Buffer += length;
@@ -1241,9 +1241,9 @@ read_append_buffer:
{
/* First copy the data to Count */
- uint len_in_buff = (uint) (info->write_pos - info->append_read_pos);
- uint copy_len;
- uint transfer_len;
+ size_t len_in_buff = (size_t) (info->write_pos - info->append_read_pos);
+ size_t copy_len;
+ size_t transfer_len;
DBUG_ASSERT(info->append_read_pos <= info->write_pos);
/*
@@ -1288,15 +1288,16 @@ read_append_buffer:
0 Success
1 An error has occurred; IO_CACHE to error state.
*/
-int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count)
+
+int _my_b_async_read(register IO_CACHE *info, uchar *Buffer, size_t Count)
{
- uint length,read_length,diff_length,left_length,use_length,org_Count;
- my_off_t max_length;
+ size_t length,read_length,diff_length,left_length,use_length,org_Count;
+ size_t max_length;
my_off_t next_pos_in_file;
- byte *read_buffer;
+ uchar *read_buffer;
memcpy(Buffer,info->read_pos,
- (size_t) (left_length=(uint) (info->read_end-info->read_pos)));
+ (left_length= (size_t) (info->read_end-info->read_pos)));
Buffer+=left_length;
org_Count=Count;
Count-=left_length;
@@ -1315,15 +1316,15 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count)
info->error= -1;
return(1);
}
- if (! (read_length = (uint) info->aio_result.result.aio_return) ||
- read_length == (uint) -1)
+ if (! (read_length= (size_t) info->aio_result.result.aio_return) ||
+ read_length == (size_t) -1)
{
my_errno=0; /* For testing */
- info->error= (read_length == (uint) -1 ? -1 :
+ info->error= (read_length == (size_t) -1 ? -1 :
(int) (read_length+left_length));
return(1);
}
- info->pos_in_file+=(uint) (info->read_end - info->request_pos);
+ info->pos_in_file+= (size_t) (info->read_end - info->request_pos);
if (info->request_pos != info->buffer)
info->request_pos=info->buffer;
@@ -1354,7 +1355,7 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count)
if (info->aio_read_pos > info->pos_in_file)
{
my_errno=EINVAL;
- return(info->read_length= -1);
+ return(info->read_length= (size_t) -1);
}
#endif
/* Copy found bytes to buffer */
@@ -1367,7 +1368,7 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count)
info->read_pos+=length;
}
else
- next_pos_in_file=(info->pos_in_file+ (uint)
+ next_pos_in_file=(info->pos_in_file+ (size_t)
(info->read_end - info->request_pos));
/* If reading large blocks, or first read or read with skip */
@@ -1386,11 +1387,11 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count)
return (1);
}
- read_length=IO_SIZE*2- (uint) (next_pos_in_file & (IO_SIZE-1));
+ read_length=IO_SIZE*2- (size_t) (next_pos_in_file & (IO_SIZE-1));
if (Count < read_length)
{ /* Small block, read to cache */
if ((read_length=my_read(info->file,info->request_pos,
- read_length, info->myflags)) == (uint) -1)
+ read_length, info->myflags)) == (size_t) -1)
return info->error= -1;
use_length=min(Count,read_length);
memcpy(Buffer,info->request_pos,(size_t) use_length);
@@ -1410,10 +1411,10 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count)
}
else
{ /* Big block, don't cache it */
- if ((read_length=my_read(info->file,Buffer,(uint) Count,info->myflags))
+ if ((read_length= my_read(info->file,Buffer, Count,info->myflags))
!= Count)
{
- info->error= read_length == (uint) -1 ? -1 : read_length+left_length;
+ info->error= read_length == (size_t) -1 ? -1 : read_length+left_length;
return 1;
}
info->read_pos=info->read_end=info->request_pos;
@@ -1421,12 +1422,12 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count)
}
}
- /* Read next block with asyncronic io */
- max_length=info->end_of_file - next_pos_in_file;
+ /* Read next block with asyncronic io */
diff_length=(next_pos_in_file & (IO_SIZE-1));
+ max_length= info->read_length - diff_length;
+ if (max_length > info->end_of_file - next_pos_in_file)
+ max_length= (size_t) (info->end_of_file - next_pos_in_file);
- if (max_length > (my_off_t) info->read_length - diff_length)
- max_length= (my_off_t) info->read_length - diff_length;
if (info->request_pos != info->buffer)
read_buffer=info->buffer;
else
@@ -1435,9 +1436,9 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count)
if (max_length)
{
info->aio_result.result.aio_errno=AIO_INPROGRESS; /* Marker for test */
- DBUG_PRINT("aioread",("filepos: %ld length: %ld",
- (ulong) next_pos_in_file,(ulong) max_length));
- if (aioread(info->file,read_buffer,(int) max_length,
+ DBUG_PRINT("aioread",("filepos: %ld length: %lu",
+ (ulong) next_pos_in_file, (ulong) max_length));
+ if (aioread(info->file,read_buffer, max_length,
(my_off_t) next_pos_in_file,MY_SEEK_SET,
&info->aio_result.result))
{ /* Skip async io */
@@ -1447,7 +1448,7 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count)
if (info->request_pos != info->buffer)
{
bmove(info->buffer,info->request_pos,
- (uint) (info->read_end - info->read_pos));
+ (size_t) (info->read_end - info->read_pos));
info->request_pos=info->buffer;
info->read_pos-=info->read_length;
info->read_end-=info->read_length;
@@ -1467,7 +1468,7 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count)
int _my_b_get(IO_CACHE *info)
{
- byte buff;
+ uchar buff;
IO_CACHE_CALLBACK pre_read,post_read;
if ((pre_read = info->pre_read))
(*pre_read)(info);
@@ -1488,9 +1489,9 @@ int _my_b_get(IO_CACHE *info)
-1 On error; my_errno contains error code.
*/
-int _my_b_write(register IO_CACHE *info, const byte *Buffer, uint Count)
+int _my_b_write(register IO_CACHE *info, const uchar *Buffer, size_t Count)
{
- uint rest_length,length;
+ size_t rest_length,length;
if (info->pos_in_file+info->buffer_length > info->end_of_file)
{
@@ -1498,7 +1499,7 @@ int _my_b_write(register IO_CACHE *info, const byte *Buffer, uint Count)
return info->error = -1;
}
- rest_length=(uint) (info->write_end - info->write_pos);
+ rest_length= (size_t) (info->write_end - info->write_pos);
memcpy(info->write_pos,Buffer,(size_t) rest_length);
Buffer+=rest_length;
Count-=rest_length;
@@ -1508,7 +1509,7 @@ int _my_b_write(register IO_CACHE *info, const byte *Buffer, uint Count)
return 1;
if (Count >= IO_SIZE)
{ /* Fill first intern buffer */
- length=Count & (uint) ~(IO_SIZE-1);
+ length=Count & (size_t) ~(IO_SIZE-1);
if (info->seek_not_done)
{
/*
@@ -1524,7 +1525,7 @@ int _my_b_write(register IO_CACHE *info, const byte *Buffer, uint Count)
}
info->seek_not_done=0;
}
- if (my_write(info->file,Buffer,(uint) length,info->myflags | MY_NABP))
+ if (my_write(info->file, Buffer, length, info->myflags | MY_NABP))
return info->error= -1;
#ifdef THREAD
@@ -1559,9 +1560,9 @@ int _my_b_write(register IO_CACHE *info, const byte *Buffer, uint Count)
the write buffer before we are ready with it.
*/
-int my_b_append(register IO_CACHE *info, const byte *Buffer, uint Count)
+int my_b_append(register IO_CACHE *info, const uchar *Buffer, size_t Count)
{
- uint rest_length,length;
+ size_t rest_length,length;
#ifdef THREAD
/*
@@ -1572,10 +1573,10 @@ int my_b_append(register IO_CACHE *info, const byte *Buffer, uint Count)
#endif
lock_append_buffer(info);
- rest_length=(uint) (info->write_end - info->write_pos);
+ rest_length= (size_t) (info->write_end - info->write_pos);
if (Count <= rest_length)
goto end;
- memcpy(info->write_pos,Buffer,(size_t) rest_length);
+ memcpy(info->write_pos, Buffer, rest_length);
Buffer+=rest_length;
Count-=rest_length;
info->write_pos+=rest_length;
@@ -1586,8 +1587,8 @@ int my_b_append(register IO_CACHE *info, const byte *Buffer, uint Count)
}
if (Count >= IO_SIZE)
{ /* Fill first intern buffer */
- length=Count & (uint) ~(IO_SIZE-1);
- if (my_write(info->file,Buffer,(uint) length,info->myflags | MY_NABP))
+ length=Count & (size_t) ~(IO_SIZE-1);
+ if (my_write(info->file,Buffer, length, info->myflags | MY_NABP))
{
unlock_append_buffer(info);
return info->error= -1;
@@ -1605,7 +1606,7 @@ end:
}
-int my_b_safe_write(IO_CACHE *info, const byte *Buffer, uint Count)
+int my_b_safe_write(IO_CACHE *info, const uchar *Buffer, size_t Count)
{
/*
Sasha: We are not writing this with the ? operator to avoid hitting
@@ -1625,10 +1626,10 @@ int my_b_safe_write(IO_CACHE *info, const byte *Buffer, uint Count)
we will never get a seek over the end of the buffer
*/
-int my_block_write(register IO_CACHE *info, const byte *Buffer, uint Count,
+int my_block_write(register IO_CACHE *info, const uchar *Buffer, size_t Count,
my_off_t pos)
{
- uint length;
+ size_t length;
int error=0;
#ifdef THREAD
@@ -1648,7 +1649,7 @@ int my_block_write(register IO_CACHE *info, const byte *Buffer, uint Count,
/* Write the part of the block that is before buffer */
length= (uint) (info->pos_in_file - pos);
if (my_pwrite(info->file, Buffer, length, pos, info->myflags | MY_NABP))
- info->error=error=-1;
+ info->error= error= -1;
Buffer+=length;
pos+= length;
Count-= length;
@@ -1658,10 +1659,10 @@ int my_block_write(register IO_CACHE *info, const byte *Buffer, uint Count,
}
/* Check if we want to write inside the used part of the buffer.*/
- length= (uint) (info->write_end - info->buffer);
+ length= (size_t) (info->write_end - info->buffer);
if (pos < info->pos_in_file + length)
{
- uint offset= (uint) (pos - info->pos_in_file);
+ size_t offset= (size_t) (pos - info->pos_in_file);
length-=offset;
if (length > Count)
length=Count;
@@ -1696,7 +1697,7 @@ int my_block_write(register IO_CACHE *info, const byte *Buffer, uint Count,
int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock)
{
- uint length;
+ size_t length;
my_bool append_cache;
my_off_t pos_in_file;
DBUG_ENTER("my_b_flush_io_cache");
@@ -1713,7 +1714,7 @@ int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock)
}
LOCK_APPEND_BUFFER;
- if ((length=(uint) (info->write_pos - info->write_buffer)))
+ if ((length=(size_t) (info->write_pos - info->write_buffer)))
{
#ifdef THREAD
/*
@@ -1821,8 +1822,8 @@ int end_io_cache(IO_CACHE *info)
info->alloced_buffer=0;
if (info->file != -1) /* File doesn't exist */
error= my_b_flush_io_cache(info,1);
- my_free((gptr) info->buffer,MYF(MY_WME));
- info->buffer=info->read_pos=(byte*) 0;
+ my_free((uchar*) info->buffer,MYF(MY_WME));
+ info->buffer=info->read_pos=(uchar*) 0;
}
if (info->type == SEQ_READ_APPEND)
{
diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c
index bdb5d057a16..8a5b91661c4 100644
--- a/mysys/mf_iocache2.c
+++ b/mysys/mf_iocache2.c
@@ -50,7 +50,7 @@
int
my_b_copy_to_file(IO_CACHE *cache, FILE *file)
{
- uint bytes_in_cache;
+ size_t bytes_in_cache;
DBUG_ENTER("my_b_copy_to_file");
/* Reinit the cache to read from the beginning of the cache */
@@ -60,7 +60,7 @@ my_b_copy_to_file(IO_CACHE *cache, FILE *file)
do
{
if (my_fwrite(file, cache->read_pos, bytes_in_cache,
- MYF(MY_WME | MY_NABP)) == (uint) -1)
+ MYF(MY_WME | MY_NABP)) == (size_t) -1)
DBUG_RETURN(1);
cache->read_pos= cache->read_end;
} while ((bytes_in_cache= my_b_fill(cache)));
@@ -175,18 +175,24 @@ void my_b_seek(IO_CACHE *info,my_off_t pos)
/*
- Fill buffer. Note that this assumes that you have already used
- all characters in the CACHE, independent of the read_pos value!
- return: 0 on error or EOF (info->error = -1 on error)
- number of characters
+ Fill buffer of the cache.
+
+ NOTES
+ This assumes that you have already used all characters in the CACHE,
+ independent of the read_pos value!
+
+ RETURN
+ 0 On error or EOF (info->error = -1 on error)
+ # Number of characters
*/
-uint my_b_fill(IO_CACHE *info)
+
+size_t my_b_fill(IO_CACHE *info)
{
my_off_t pos_in_file=(info->pos_in_file+
- (uint) (info->read_end - info->buffer));
- my_off_t max_length;
- uint diff_length,length;
+ (size_t) (info->read_end - info->buffer));
+ size_t diff_length, length, max_length;
+
if (info->seek_not_done)
{ /* File touched, do seek */
if (my_seek(info->file,pos_in_file,MY_SEEK_SET,MYF(0)) ==
@@ -197,17 +203,18 @@ uint my_b_fill(IO_CACHE *info)
}
info->seek_not_done=0;
}
- diff_length=(uint) (pos_in_file & (IO_SIZE-1));
- max_length= (my_off_t) (info->end_of_file - pos_in_file);
- if (max_length > (my_off_t) (info->read_length-diff_length))
- max_length=(my_off_t) (info->read_length-diff_length);
+ diff_length=(size_t) (pos_in_file & (IO_SIZE-1));
+ max_length=(info->read_length-diff_length);
+ if (max_length >= (info->end_of_file - pos_in_file))
+ max_length= (size_t) (info->end_of_file - pos_in_file);
+
if (!max_length)
{
info->error= 0;
return 0; /* EOF */
}
- else if ((length=my_read(info->file,info->buffer,(uint) max_length,
- info->myflags)) == (uint) -1)
+ if ((length= my_read(info->file,info->buffer,max_length,
+ info->myflags)) == (size_t) -1)
{
info->error= -1;
return 0;
@@ -226,15 +233,17 @@ uint my_b_fill(IO_CACHE *info)
If buffer is full then to[max_length-1] will be set to \0.
*/
-uint my_b_gets(IO_CACHE *info, char *to, uint max_length)
+size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length)
{
char *start = to;
- uint length;
+ size_t length;
max_length--; /* Save place for end \0 */
+
/* Calculate number of characters in buffer */
if (!(length= my_b_bytes_in_cache(info)) &&
!(length= my_b_fill(info)))
return 0;
+
for (;;)
{
char *pos,*end;
@@ -246,7 +255,7 @@ uint my_b_gets(IO_CACHE *info, char *to, uint max_length)
{
info->read_pos=pos;
*to='\0';
- return (uint) (to-start);
+ return (size_t) (to-start);
}
}
if (!(max_length-=length))
@@ -254,7 +263,7 @@ uint my_b_gets(IO_CACHE *info, char *to, uint max_length)
/* Found enough charcters; Return found string */
info->read_pos=pos;
*to='\0';
- return (uint) (to-start);
+ return (size_t) (to-start);
}
if (!(length=my_b_fill(info)))
return 0;
@@ -265,26 +274,22 @@ uint my_b_gets(IO_CACHE *info, char *to, uint max_length)
my_off_t my_b_filelength(IO_CACHE *info)
{
if (info->type == WRITE_CACHE)
- {
return my_b_tell(info);
- }
- else
- {
- info->seek_not_done=1;
- return my_seek(info->file,0L,MY_SEEK_END,MYF(0));
- }
+
+ info->seek_not_done= 1;
+ return my_seek(info->file, 0L, MY_SEEK_END, MYF(0));
}
/*
Simple printf version. Supports '%s', '%d', '%u', "%ld" and "%lu"
Used for logging in MySQL
- returns number of written character, or (uint) -1 on error
+ returns number of written character, or (size_t) -1 on error
*/
-uint my_b_printf(IO_CACHE *info, const char* fmt, ...)
+size_t my_b_printf(IO_CACHE *info, const char* fmt, ...)
{
- int result;
+ size_t result;
va_list args;
va_start(args,fmt);
result=my_b_vprintf(info, fmt, args);
@@ -293,9 +298,9 @@ uint my_b_printf(IO_CACHE *info, const char* fmt, ...)
}
-uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
+size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
{
- uint out_length=0;
+ size_t out_length= 0;
uint minimum_width; /* as yet unimplemented */
uint minimum_width_sign;
uint precision; /* as yet unimplemented for anything but %b */
@@ -312,19 +317,17 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
{
/* Copy everything until '%' or end of string */
const char *start=fmt;
- uint length;
+ size_t length;
for (; (*fmt != '\0') && (*fmt != '%'); fmt++) ;
- length= (uint) (fmt - start);
+ length= (size_t) (fmt - start);
out_length+=length;
if (my_b_write(info, start, length))
goto err;
if (*fmt == '\0') /* End of format */
- {
return out_length;
- }
/*
By this point, *fmt must be a percent; Keep track of this location and
@@ -339,10 +342,13 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
minimum_width_sign= 1;
/* Skip if max size is used (to be compatible with printf) */
while (*fmt == '-') { fmt++; minimum_width_sign= -1; }
- if (*fmt == '*') {
+ if (*fmt == '*')
+ {
precision= (int) va_arg(args, int);
fmt++;
- } else {
+ }
+ else
+ {
while (my_isdigit(&my_charset_latin1, *fmt)) {
minimum_width=(minimum_width * 10) + (*fmt - '0');
fmt++;
@@ -350,12 +356,15 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
}
minimum_width*= minimum_width_sign;
- if (*fmt == '.') {
+ if (*fmt == '.')
+ {
fmt++;
if (*fmt == '*') {
precision= (int) va_arg(args, int);
fmt++;
- } else {
+ }
+ else
+ {
while (my_isdigit(&my_charset_latin1, *fmt)) {
precision=(precision * 10) + (*fmt - '0');
fmt++;
@@ -366,7 +375,7 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
if (*fmt == 's') /* String parameter */
{
reg2 char *par = va_arg(args, char *);
- uint length2 = (uint) strlen(par);
+ size_t length2 = strlen(par);
/* TODO: implement minimum width and precision */
out_length+= length2;
if (my_b_write(info, par, length2))
@@ -382,14 +391,14 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
else if (*fmt == 'd' || *fmt == 'u') /* Integer parameter */
{
register int iarg;
- uint length2;
+ size_t length2;
char buff[17];
iarg = va_arg(args, int);
if (*fmt == 'd')
- length2= (uint) (int10_to_str((long) iarg,buff, -10) - buff);
+ length2= (size_t) (int10_to_str((long) iarg,buff, -10) - buff);
else
- length2= (uint) (int10_to_str((long) (uint) iarg,buff,10)- buff);
+ length2= (size_t) (int10_to_str((long) (uint) iarg,buff,10)- buff);
out_length+= length2;
if (my_b_write(info, buff, length2))
goto err;
@@ -398,14 +407,14 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
/* long parameter */
{
register long iarg;
- uint length2;
+ size_t length2;
char buff[17];
iarg = va_arg(args, long);
if (*++fmt == 'd')
- length2= (uint) (int10_to_str(iarg,buff, -10) - buff);
+ length2= (size_t) (int10_to_str(iarg,buff, -10) - buff);
else
- length2= (uint) (int10_to_str(iarg,buff,10)- buff);
+ length2= (size_t) (int10_to_str(iarg,buff,10)- buff);
out_length+= length2;
if (my_b_write(info, buff, length2))
goto err;
@@ -421,5 +430,5 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
return out_length;
err:
- return (uint) -1;
+ return (size_t) -1;
}
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 86394fec239..a3d0a8f94fb 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -136,7 +136,7 @@ struct st_block_link
struct st_hash_link *hash_link; /* backward ptr to referring hash_link */
KEYCACHE_WQUEUE wqueue[2]; /* queues on waiting requests for new/old pages */
uint requests; /* number of requests for the block */
- byte *buffer; /* buffer for the block page */
+ uchar *buffer; /* buffer for the block page */
uint offset; /* beginning of modified data in the buffer */
uint length; /* end of data in the buffer */
uint status; /* state of the block */
@@ -370,11 +370,11 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
keycache->hash_link_root= (HASH_LINK*) ((char*) keycache->hash_root +
ALIGN_SIZE((sizeof(HASH_LINK*) *
keycache->hash_entries)));
- bzero((byte*) keycache->block_root,
+ bzero((uchar*) keycache->block_root,
keycache->disk_blocks * sizeof(BLOCK_LINK));
- bzero((byte*) keycache->hash_root,
+ bzero((uchar*) keycache->hash_root,
keycache->hash_entries * sizeof(HASH_LINK*));
- bzero((byte*) keycache->hash_link_root,
+ bzero((uchar*) keycache->hash_link_root,
keycache->hash_links * sizeof(HASH_LINK));
keycache->hash_links_used= 0;
keycache->free_hash_list= NULL;
@@ -408,9 +408,9 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
keycache->disk_blocks, (long) keycache->block_root,
keycache->hash_entries, (long) keycache->hash_root,
keycache->hash_links, (long) keycache->hash_link_root));
- bzero((gptr) keycache->changed_blocks,
+ bzero((uchar*) keycache->changed_blocks,
sizeof(keycache->changed_blocks[0]) * CHANGED_BLOCKS_HASH);
- bzero((gptr) keycache->file_blocks,
+ bzero((uchar*) keycache->file_blocks,
sizeof(keycache->file_blocks[0]) * CHANGED_BLOCKS_HASH);
}
@@ -423,12 +423,12 @@ err:
keycache->blocks= 0;
if (keycache->block_mem)
{
- my_large_free((gptr) keycache->block_mem, MYF(0));
+ my_large_free((uchar*) keycache->block_mem, MYF(0));
keycache->block_mem= NULL;
}
if (keycache->block_root)
{
- my_free((gptr) keycache->block_root, MYF(0));
+ my_free((uchar*) keycache->block_root, MYF(0));
keycache->block_root= NULL;
}
my_errno= error;
@@ -631,9 +631,9 @@ void end_key_cache(KEY_CACHE *keycache, my_bool cleanup)
{
if (keycache->block_mem)
{
- my_large_free((gptr) keycache->block_mem, MYF(0));
+ my_large_free((uchar*) keycache->block_mem, MYF(0));
keycache->block_mem= NULL;
- my_free((gptr) keycache->block_root, MYF(0));
+ my_free((uchar*) keycache->block_root, MYF(0));
keycache->block_root= NULL;
}
keycache->disk_blocks= -1;
@@ -1492,7 +1492,7 @@ restart:
block->buffer= ADD_TO_PTR(keycache->block_mem,
((ulong) keycache->blocks_used*
keycache->key_cache_block_size),
- byte*);
+ uchar*);
keycache->blocks_used++;
}
keycache->blocks_unused--;
@@ -1783,15 +1783,15 @@ static void read_block(KEY_CACHE *keycache __attribute__((unused)),
have to be a multiple of key_cache_block_size;
*/
-byte *key_cache_read(KEY_CACHE *keycache,
+uchar *key_cache_read(KEY_CACHE *keycache,
File file, my_off_t filepos, int level,
- byte *buff, uint length,
+ uchar *buff, uint length,
uint block_length __attribute__((unused)),
int return_buffer __attribute__((unused)))
{
int error=0;
uint offset= 0;
- byte *start= buff;
+ uchar *start= buff;
DBUG_ENTER("key_cache_read");
DBUG_PRINT("enter", ("fd: %u pos: %lu length: %u",
(uint) file, (ulong) filepos, length));
@@ -1880,7 +1880,7 @@ byte *key_cache_read(KEY_CACHE *keycache,
keycache_pthread_mutex_unlock(&keycache->cache_lock);
if (status & BLOCK_ERROR)
- DBUG_RETURN((byte *) 0);
+ DBUG_RETURN((uchar *) 0);
#ifndef THREAD
/* This is only true if we where able to read everything in one block */
@@ -1900,9 +1900,9 @@ no_key_cache: /* Key cache is not used */
/* We can't use mutex here as the key cache may not be initialized */
keycache->global_cache_r_requests++;
keycache->global_cache_read++;
- if (my_pread(file, (byte*) buff, length, filepos+offset, MYF(MY_NABP)))
+ if (my_pread(file, (uchar*) buff, length, filepos+offset, MYF(MY_NABP)))
error= 1;
- DBUG_RETURN(error ? (byte*) 0 : start);
+ DBUG_RETURN(error ? (uchar*) 0 : start);
}
@@ -1928,7 +1928,7 @@ no_key_cache: /* Key cache is not used */
int key_cache_insert(KEY_CACHE *keycache,
File file, my_off_t filepos, int level,
- byte *buff, uint length)
+ uchar *buff, uint length)
{
DBUG_ENTER("key_cache_insert");
DBUG_PRINT("enter", ("fd: %u pos: %lu length: %u",
@@ -2048,7 +2048,7 @@ int key_cache_insert(KEY_CACHE *keycache,
int key_cache_write(KEY_CACHE *keycache,
File file, my_off_t filepos, int level,
- byte *buff, uint length,
+ uchar *buff, uint length,
uint block_length __attribute__((unused)),
int dont_write)
{
@@ -2107,7 +2107,7 @@ int key_cache_write(KEY_CACHE *keycache,
{
keycache->global_cache_w_requests++;
keycache->global_cache_write++;
- if (my_pwrite(file, (byte*) buff, length, filepos,
+ if (my_pwrite(file, (uchar*) buff, length, filepos,
MYF(MY_NABP | MY_WAIT_IF_FULL)))
error=1;
}
@@ -2174,7 +2174,7 @@ no_key_cache:
{
keycache->global_cache_w_requests++;
keycache->global_cache_write++;
- if (my_pwrite(file, (byte*) buff, length, filepos,
+ if (my_pwrite(file, (uchar*) buff, length, filepos,
MYF(MY_NABP | MY_WAIT_IF_FULL)))
error=1;
}
@@ -2269,7 +2269,7 @@ static int flush_cached_blocks(KEY_CACHE *keycache,
As all blocks referred in 'cache' are marked by BLOCK_IN_FLUSH
we are guarunteed no thread will change them
*/
- qsort((byte*) cache, count, sizeof(*cache), (qsort_cmp) cmp_sec_link);
+ qsort((uchar*) cache, count, sizeof(*cache), (qsort_cmp) cmp_sec_link);
keycache_pthread_mutex_lock(&keycache->cache_lock);
for ( ; cache != end ; cache++)
@@ -2521,7 +2521,7 @@ restart:
test_key_cache(keycache, "end of flush_key_blocks", 0););
#endif
if (cache != cache_buff)
- my_free((gptr) cache, MYF(0));
+ my_free((uchar*) cache, MYF(0));
if (last_errno)
errno=last_errno; /* Return first error */
DBUG_RETURN(last_errno != 0);
diff --git a/mysys/mf_keycaches.c b/mysys/mf_keycaches.c
index 51ad54159e5..6227a05ce06 100644
--- a/mysys/mf_keycaches.c
+++ b/mysys/mf_keycaches.c
@@ -44,9 +44,9 @@
typedef struct st_safe_hash_entry
{
- byte *key;
+ uchar *key;
uint length;
- byte *data;
+ uchar *data;
struct st_safe_hash_entry *next, **prev;
} SAFE_HASH_ENTRY;
@@ -57,7 +57,7 @@ typedef struct st_safe_hash_with_default
rw_lock_t mutex;
#endif
HASH hash;
- byte *default_value;
+ uchar *default_value;
SAFE_HASH_ENTRY *root;
} SAFE_HASH;
@@ -71,18 +71,18 @@ typedef struct st_safe_hash_with_default
static void safe_hash_entry_free(SAFE_HASH_ENTRY *entry)
{
DBUG_ENTER("free_assign_entry");
- my_free((gptr) entry, MYF(0));
+ my_free((uchar*) entry, MYF(0));
DBUG_VOID_RETURN;
}
/* Get key and length for a SAFE_HASH_ENTRY */
-static byte *safe_hash_entry_get(SAFE_HASH_ENTRY *entry, uint *length,
- my_bool not_used __attribute__((unused)))
+static uchar *safe_hash_entry_get(SAFE_HASH_ENTRY *entry, size_t *length,
+ my_bool not_used __attribute__((unused)))
{
*length=entry->length;
- return (byte*) entry->key;
+ return (uchar*) entry->key;
}
@@ -105,7 +105,7 @@ static byte *safe_hash_entry_get(SAFE_HASH_ENTRY *entry, uint *length,
*/
static my_bool safe_hash_init(SAFE_HASH *hash, uint elements,
- byte *default_value)
+ uchar *default_value)
{
DBUG_ENTER("safe_hash");
if (hash_init(&hash->hash, &my_charset_bin, elements,
@@ -147,9 +147,9 @@ static void safe_hash_free(SAFE_HASH *hash)
Return the value stored for a key or default value if no key
*/
-static byte *safe_hash_search(SAFE_HASH *hash, const byte *key, uint length)
+static uchar *safe_hash_search(SAFE_HASH *hash, const uchar *key, uint length)
{
- byte *result;
+ uchar *result;
DBUG_ENTER("safe_hash_search");
rw_rdlock(&hash->mutex);
result= hash_search(&hash->hash, key, length);
@@ -183,8 +183,8 @@ static byte *safe_hash_search(SAFE_HASH *hash, const byte *key, uint length)
1 error (Can only be EOM). In this case my_message() is called.
*/
-static my_bool safe_hash_set(SAFE_HASH *hash, const byte *key, uint length,
- byte *data)
+static my_bool safe_hash_set(SAFE_HASH *hash, const uchar *key, uint length,
+ uchar *data)
{
SAFE_HASH_ENTRY *entry;
my_bool error= 0;
@@ -206,7 +206,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const byte *key, uint length,
/* unlink entry from list */
if ((*entry->prev= entry->next))
entry->next->prev= entry->prev;
- hash_delete(&hash->hash, (byte*) entry);
+ hash_delete(&hash->hash, (uchar*) entry);
goto end;
}
if (entry)
@@ -222,7 +222,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const byte *key, uint length,
error= 1;
goto end;
}
- entry->key= (byte*) (entry +1);
+ entry->key= (uchar*) (entry +1);
memcpy((char*) entry->key, (char*) key, length);
entry->length= length;
entry->data= data;
@@ -231,7 +231,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const byte *key, uint length,
entry->next->prev= &entry->next;
entry->prev= &hash->root;
hash->root= entry;
- if (my_hash_insert(&hash->hash, (byte*) entry))
+ if (my_hash_insert(&hash->hash, (uchar*) entry))
{
/* This can only happen if hash got out of memory */
my_free((char*) entry, MYF(0));
@@ -261,7 +261,7 @@ end:
default value.
*/
-static void safe_hash_change(SAFE_HASH *hash, byte *old_data, byte *new_data)
+static void safe_hash_change(SAFE_HASH *hash, uchar *old_data, uchar *new_data)
{
SAFE_HASH_ENTRY *entry, *next;
DBUG_ENTER("safe_hash_set");
@@ -277,7 +277,7 @@ static void safe_hash_change(SAFE_HASH *hash, byte *old_data, byte *new_data)
{
if ((*entry->prev= entry->next))
entry->next->prev= entry->prev;
- hash_delete(&hash->hash, (byte*) entry);
+ hash_delete(&hash->hash, (uchar*) entry);
}
else
entry->data= new_data;
@@ -299,7 +299,7 @@ static SAFE_HASH key_cache_hash;
my_bool multi_keycache_init(void)
{
- return safe_hash_init(&key_cache_hash, 16, (byte*) dflt_key_cache);
+ return safe_hash_init(&key_cache_hash, 16, (uchar*) dflt_key_cache);
}
@@ -325,7 +325,7 @@ void multi_keycache_free(void)
key cache to use
*/
-KEY_CACHE *multi_key_cache_search(byte *key, uint length)
+KEY_CACHE *multi_key_cache_search(uchar *key, uint length)
{
if (!key_cache_hash.hash.records)
return dflt_key_cache;
@@ -349,15 +349,15 @@ KEY_CACHE *multi_key_cache_search(byte *key, uint length)
*/
-my_bool multi_key_cache_set(const byte *key, uint length,
+my_bool multi_key_cache_set(const uchar *key, uint length,
KEY_CACHE *key_cache)
{
- return safe_hash_set(&key_cache_hash, key, length, (byte*) key_cache);
+ return safe_hash_set(&key_cache_hash, key, length, (uchar*) key_cache);
}
void multi_key_cache_change(KEY_CACHE *old_data,
KEY_CACHE *new_data)
{
- safe_hash_change(&key_cache_hash, (byte*) old_data, (byte*) new_data);
+ safe_hash_change(&key_cache_hash, (uchar*) old_data, (uchar*) new_data);
}
diff --git a/mysys/mf_loadpath.c b/mysys/mf_loadpath.c
index ffa83cb20ec..48a69207839 100644
--- a/mysys/mf_loadpath.c
+++ b/mysys/mf_loadpath.c
@@ -23,7 +23,7 @@
/* if there is no path, prepend with own_path_prefix if given */
/* else unpack path according to current dir */
-my_string my_load_path(my_string to, const char *path,
+char * my_load_path(char * to, const char *path,
const char *own_path_prefix)
{
char buff[FN_REFLEN];
@@ -36,7 +36,7 @@ my_string my_load_path(my_string to, const char *path,
test_if_hard_path(path))
VOID(strmov(buff,path));
else if ((is_cur=(path[0] == FN_CURLIB && path[1] == FN_LIBCHAR)) ||
- (is_prefix((gptr) path,FN_PARENTDIR)) ||
+ (is_prefix(path,FN_PARENTDIR)) ||
! own_path_prefix)
{
if (is_cur)
diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c
index 1b83c6fda10..99c0c959d94 100644
--- a/mysys/mf_pack.c
+++ b/mysys/mf_pack.c
@@ -24,17 +24,17 @@
#include <descrip.h>
#endif /* VMS */
-static my_string NEAR_F expand_tilde(my_string *path);
+static char * NEAR_F expand_tilde(char * *path);
/* Pack a dirname ; Changes HOME to ~/ and current dev to ./ */
/* from is a dirname (from dirname() ?) ending with FN_LIBCHAR */
/* to may be == from */
-void pack_dirname(my_string to, const char *from)
+void pack_dirname(char * to, const char *from)
{
int cwd_err;
- uint d_length,length,buff_length;
- my_string start;
+ size_t d_length,length,buff_length;
+ char * start;
char buff[FN_REFLEN];
DBUG_ENTER("pack_dirname");
@@ -50,13 +50,13 @@ void pack_dirname(my_string to, const char *from)
if (!(cwd_err= my_getwd(buff,FN_REFLEN,MYF(0))))
{
- buff_length= (uint) strlen(buff);
- d_length=(uint) (start-to);
+ buff_length= strlen(buff);
+ d_length= (size_t) (start-to);
if ((start == to ||
(buff_length == d_length && !bcmp(buff,start,d_length))) &&
*start != FN_LIBCHAR && *start)
{ /* Put current dir before */
- bchange(to,d_length,buff,buff_length,(uint) strlen(to)+1);
+ bchange(to,d_length,buff,buff_length,strlen(to)+1);
}
}
@@ -65,7 +65,7 @@ void pack_dirname(my_string to, const char *from)
length=0;
if (home_dir)
{
- length= (uint) strlen(home_dir);
+ length= strlen(home_dir);
if (home_dir[length-1] == FN_LIBCHAR)
length--; /* Don't test last '/' */
}
@@ -89,7 +89,7 @@ void pack_dirname(my_string to, const char *from)
}
if (is_prefix(to,buff))
{
- length= (uint) strlen(buff);
+ length= strlen(buff);
if (to[length])
(void) strmov_overlapp(to,to+length); /* Remove everything before */
else
@@ -126,12 +126,12 @@ void pack_dirname(my_string to, const char *from)
# length of new name
*/
-uint cleanup_dirname(register my_string to, const char *from)
+size_t cleanup_dirname(register char *to, const char *from)
{
- reg5 uint length;
- reg2 my_string pos;
- reg3 my_string from_ptr;
- reg4 my_string start;
+ reg5 size_t length;
+ reg2 char * pos;
+ reg3 char * from_ptr;
+ reg4 char * start;
char parent[5], /* for "FN_PARENTDIR" */
buff[FN_REFLEN+1],*end_parentdir;
#ifdef BACKSLASH_MBTAIL
@@ -141,17 +141,17 @@ uint cleanup_dirname(register my_string to, const char *from)
DBUG_PRINT("enter",("from: '%s'",from));
start=buff;
- from_ptr=(my_string) from;
+ from_ptr=(char *) from;
#ifdef FN_DEVCHAR
if ((pos=strrchr(from_ptr,FN_DEVCHAR)) != 0)
{ /* Skip device part */
- length=(uint) (pos-from_ptr)+1;
+ length=(size_t) (pos-from_ptr)+1;
start=strnmov(buff,from_ptr,length); from_ptr+=length;
}
#endif
parent[0]=FN_LIBCHAR;
- length=(uint) (strmov(parent+1,FN_PARENTDIR)-parent);
+ length=(size_t) (strmov(parent+1,FN_PARENTDIR)-parent);
for (pos=start ; (*pos= *from_ptr++) != 0 ; pos++)
{
#ifdef BACKSLASH_MBTAIL
@@ -167,7 +167,7 @@ uint cleanup_dirname(register my_string to, const char *from)
*pos = FN_LIBCHAR;
if (*pos == FN_LIBCHAR)
{
- if ((uint) (pos-start) > length && bcmp(pos-length,parent,length) == 0)
+ if ((size_t) (pos-start) > length && bcmp(pos-length,parent,length) == 0)
{ /* If .../../; skip prev */
pos-=length;
if (pos != start)
@@ -206,7 +206,7 @@ uint cleanup_dirname(register my_string to, const char *from)
}
}
}
- else if ((uint) (pos-start) == length-1 &&
+ else if ((size_t) (pos-start) == length-1 &&
!bcmp(start,parent+1,length-1))
start=pos; /* Starts with "../" */
else if (pos-start > 0 && pos[-1] == FN_LIBCHAR)
@@ -228,7 +228,7 @@ uint cleanup_dirname(register my_string to, const char *from)
}
(void) strmov(to,buff);
DBUG_PRINT("exit",("to: '%s'",to));
- DBUG_RETURN((uint) (pos-buff));
+ DBUG_RETURN((size_t) (pos-buff));
} /* cleanup_dirname */
@@ -251,7 +251,7 @@ void symdirget(char *dir)
if (dir[0] && pos[-1] != FN_DEVCHAR && my_access(dir, F_OK))
{
File file;
- uint length;
+ size_t length;
char temp= *(--pos); /* May be "/" or "\" */
strmov(pos,".sym");
file= my_open(dir, O_RDONLY, MYF(0));
@@ -268,7 +268,7 @@ void symdirget(char *dir)
if (pos == buff || pos[-1] != FN_LIBCHAR)
*pos++=FN_LIBCHAR;
- strmake(dir,buff, (uint) (pos-buff));
+ strmake(dir,buff, (size_t) (pos-buff));
}
my_close(file, MYF(0));
}
@@ -296,14 +296,14 @@ void symdirget(char *dir)
Length of new directory name (= length of to)
*/
-uint unpack_dirname(my_string to, const char *from)
+size_t unpack_dirname(char * to, const char *from)
{
- uint length,h_length;
+ size_t length, h_length;
char buff[FN_REFLEN+1+4],*suffix,*tilde_expansion;
DBUG_ENTER("unpack_dirname");
- (void) intern_filename(buff,from); /* Change to intern name */
- length= (uint) strlen(buff); /* Fix that '/' is last */
+ (void) intern_filename(buff,from); /* Change to intern name */
+ length= strlen(buff); /* Fix that '/' is last */
if (length &&
#ifdef FN_DEVCHAR
buff[length-1] != FN_DEVCHAR &&
@@ -320,8 +320,8 @@ uint unpack_dirname(my_string to, const char *from)
suffix=buff+1; tilde_expansion=expand_tilde(&suffix);
if (tilde_expansion)
{
- length-=(uint) (suffix-buff)-1;
- if (length+(h_length= (uint) strlen(tilde_expansion)) <= FN_REFLEN)
+ length-= (size_t) (suffix-buff)-1;
+ if (length+(h_length= strlen(tilde_expansion)) <= FN_REFLEN)
{
if (tilde_expansion[h_length-1] == FN_LIBCHAR)
h_length--;
@@ -344,7 +344,7 @@ uint unpack_dirname(my_string to, const char *from)
/* Expand tilde to home or user-directory */
/* Path is reset to point at FN_LIBCHAR after ~xxx */
-static my_string NEAR_F expand_tilde(my_string *path)
+static char * NEAR_F expand_tilde(char * *path)
{
if (path[0][0] == FN_LIBCHAR)
return home_dir; /* ~/ expanded to home */
@@ -366,7 +366,7 @@ static my_string NEAR_F expand_tilde(my_string *path)
}
}
#endif
- return (my_string) 0;
+ return (char *) 0;
}
@@ -387,13 +387,13 @@ static my_string NEAR_F expand_tilde(my_string *path)
*/
-uint unpack_filename(my_string to, const char *from)
+size_t unpack_filename(char * to, const char *from)
{
- uint length,n_length;
+ size_t length, n_length, buff_length;
char buff[FN_REFLEN];
DBUG_ENTER("unpack_filename");
- length=dirname_part(buff,from); /* copy & convert dirname */
+ length=dirname_part(buff, from, &buff_length);/* copy & convert dirname */
n_length=unpack_dirname(buff,buff);
if (n_length+strlen(from+length) < FN_REFLEN)
{
@@ -410,10 +410,10 @@ uint unpack_filename(my_string to, const char *from)
/* Used before system command's like open(), create() .. */
/* Returns length of to */
-uint system_filename(my_string to, const char *from)
+size_t system_filename(char * to, const char *from)
{
#ifndef FN_C_BEFORE_DIR
- return (uint) (strmake(to,from,FN_REFLEN-1)-to);
+ return (size_t) (strmake(to,from,FN_REFLEN-1)-to);
#else /* VMS */
/* change 'dev:lib/xxx' to 'dev:[lib]xxx' */
@@ -423,8 +423,9 @@ uint system_filename(my_string to, const char *from)
/* change '/x/y/z to '[x.y]x' */
/* change 'dev:/x' to 'dev:[000000]x' */
- int libchar_found,length;
- my_string to_pos,from_pos,pos;
+ int libchar_found;
+ size_t length;
+ char * to_pos,from_pos,pos;
char buff[FN_REFLEN];
DBUG_ENTER("system_filename");
@@ -434,7 +435,7 @@ uint system_filename(my_string to, const char *from)
if ((pos=strrchr(from_pos,FN_DEVCHAR))) /* Skip device part */
{
pos++;
- to_pos=strnmov(to,from_pos,(size_s) (pos-from_pos));
+ to_pos=strnmov(to,from_pos,(size_t) (pos-from_pos));
from_pos=pos;
}
else
@@ -465,115 +466,30 @@ uint system_filename(my_string to, const char *from)
from_pos+strlen(FN_PARENTDIR) == pos)
to_pos=strmov(to_pos,FN_C_PARENT_DIR); /* Found '../' */
else
- to_pos=strnmov(to_pos,from_pos,(size_s) (pos-from_pos));
+ to_pos=strnmov(to_pos,from_pos,(size_t) (pos-from_pos));
from_pos=pos+1;
}
*(to_pos++)=FN_C_AFTER_DIR;
}
- length=(int) (strmov(to_pos,from_pos)-to);
+ length= (size_t) (strmov(to_pos,from_pos)-to);
DBUG_PRINT("exit",("name: '%s'",to));
- DBUG_RETURN((uint) length);
+ DBUG_RETURN(length);
#endif
} /* system_filename */
/* Fix a filename to intern (UNIX format) */
-my_string intern_filename(my_string to, const char *from)
+char *intern_filename(char *to, const char *from)
{
-#ifndef VMS
- {
- uint length;
- char buff[FN_REFLEN];
- if (from == to)
- { /* Dirname may destroy from */
- strmov(buff,from);
- from=buff;
- }
- length=dirname_part(to,from); /* Copy dirname & fix chars */
- (void) strcat(to,from+length);
- return (to);
- }
-#else /* VMS */
-
- /* change 'dev:[lib]xxx' to 'dev:lib/xxx' */
- /* change 'dev:xxx' to 'dev:xxx' */
- /* change 'dev:x/y/[.lib]' to 'dev:x/y/lib/ */
- /* change '[.lib]' to './lib/' */
- /* change '[x.y]' or '[x.][y]' or '[x][.y]' to '/x/y/' */
- /* change '[000000.x] or [x.000000]' to '/x/' */
-
- int par_length,root_length;
- my_string pos,from_pos,to_pos,end_pos;
+ size_t length, to_length;
char buff[FN_REFLEN];
-
- convert_dirname(buff,from,NullS); /* change '<>' to '[]' */
- from_pos=buff;
- if ((pos=strrchr(from_pos,FN_DEVCHAR))) /* Skip device part */
- {
- pos++;
- to_pos=strnmov(to,from_pos,(size_s) (pos-from_pos));
- from_pos=pos;
- }
- else
- to_pos=to;
-
- root_length=strlen(FN_C_ROOT_DIR);
- if ((pos = strchr(from_pos,FN_C_BEFORE_DIR)) &&
- (end_pos = strrchr(pos+1,FN_C_AFTER_DIR)))
- {
- to_pos=strnmov(to_pos,from_pos,(size_s) (pos-from_pos));
- /* Copy all between ':' and '[' */
- from_pos=pos+1;
- if (strinstr(from_pos,FN_C_ROOT_DIR) == 1 &&
- (from_pos[root_length] == FN_C_DIR_SEP ||
- from_pos[root_length] == FN_C_AFTER_DIR))
- {
- from_pos+=root_length+1;
- }
- else if (*from_pos == FN_C_DIR_SEP)
- *(to_pos++) = FN_CURLIB; /* Set ./ first */
- *(to_pos++) = FN_LIBCHAR;
-
- par_length=strlen(FN_C_PARENT_DIR);
- pos=to_pos;
- for (; from_pos <= end_pos ; from_pos++)
- {
- switch (*from_pos) {
- case FN_C_DIR_SEP:
- case FN_C_AFTER_DIR:
- if (pos != to_pos)
- {
- if ((int) (to_pos-pos) == root_length &&
- is_suffix(pos,FN_C_ROOT_DIR))
- to_pos=pos; /* remove root-pos */
- else
- {
- *(to_pos++)=FN_LIBCHAR; /* Find lib */
- pos=to_pos;
- }
- }
- break;
- case FN_C_BEFORE_DIR:
- break;
- case '-': /* *(FN_C_PARENT_DIR): */
- if (to_pos[-1] == FN_LIBCHAR &&
- strncmp(from_pos,FN_C_PARENT_DIR,par_length) == 0)
- { /* Change '-' to '..' */
- to_pos=strmov(to_pos,FN_PARENTDIR);
- *(to_pos++)=FN_LIBCHAR;
- pos=to_pos;
- from_pos+=par_length-1;
- break;
- }
- /* Fall through */
- default:
- *(to_pos++)= *from_pos;
- break;
- }
- }
+ if (from == to)
+ { /* Dirname may destroy from */
+ strmov(buff,from);
+ from=buff;
}
- (void) strmov(to_pos,from_pos);
+ length= dirname_part(to, from, &to_length); /* Copy dirname & fix chars */
+ (void) strmov(to + to_length,from+length);
return (to);
-#endif /* VMS */
} /* intern_filename */
diff --git a/mysys/mf_path.c b/mysys/mf_path.c
index 00e6b2046b9..7baded9d715 100644
--- a/mysys/mf_path.c
+++ b/mysys/mf_path.c
@@ -29,16 +29,18 @@ static char *find_file_in_path(char *to,const char *name);
own_path_name_part is concatinated to result.
my_path puts result in to and returns to */
-my_string my_path(my_string to, const char *progname,
- const char *own_pathname_part)
+char * my_path(char * to, const char *progname,
+ const char *own_pathname_part)
{
- my_string start,end,prog;
+ char *start, *end, *prog;
+ size_t to_length;
DBUG_ENTER("my_path");
start=to; /* Return this */
- if (progname && (dirname_part(to, progname) ||
+ if (progname && (dirname_part(to, progname, &to_length) ||
find_file_in_path(to,progname) ||
- ((prog=getenv("_")) != 0 && dirname_part(to,prog))))
+ ((prog=getenv("_")) != 0 &&
+ dirname_part(to, prog, &to_length))))
{
VOID(intern_filename(to,to));
if (!test_if_hard_path(to))
diff --git a/mysys/mf_radix.c b/mysys/mf_radix.c
index 6b750181558..582ca76b8f8 100644
--- a/mysys/mf_radix.c
+++ b/mysys/mf_radix.c
@@ -25,7 +25,7 @@
/* Radixsort */
-void radixsort_for_str_ptr(uchar **base, uint number_of_elements, size_s size_of_element, uchar **buffer)
+void radixsort_for_str_ptr(uchar **base, uint number_of_elements, size_t size_of_element, uchar **buffer)
{
uchar **end,**ptr,**buffer_ptr;
uint32 *count_ptr,*count_end,count[256];
@@ -34,7 +34,7 @@ void radixsort_for_str_ptr(uchar **base, uint number_of_elements, size_s size_of
end=base+number_of_elements; count_end=count+256;
for (pass=(int) size_of_element-1 ; pass >= 0 ; pass--)
{
- bzero((gptr) count,sizeof(uint32)*256);
+ bzero((uchar*) count,sizeof(uint32)*256);
for (ptr= base ; ptr < end ; ptr++)
count[ptr[0][pass]]++;
if (count[0] == number_of_elements)
diff --git a/mysys/mf_same.c b/mysys/mf_same.c
index e7cdb012c9f..6738dc8051e 100644
--- a/mysys/mf_same.c
+++ b/mysys/mf_same.c
@@ -25,14 +25,15 @@
Returns 'to'.
*/
-my_string fn_same(char *to, const char *name, int flag)
+char * fn_same(char *to, const char *name, int flag)
{
char dev[FN_REFLEN];
const char *ext;
+ size_t dev_length;
DBUG_ENTER("fn_same");
DBUG_PRINT("enter",("to: %s name: %s flag: %d",to,name,flag));
- if ((ext=strrchr(name+dirname_part(dev,name),FN_EXTCHAR)) == 0)
+ if ((ext=strrchr(name+dirname_part(dev, name, &dev_length),FN_EXTCHAR)) == 0)
ext="";
DBUG_RETURN(fn_format(to,to,dev,ext,flag));
diff --git a/mysys/mf_sort.c b/mysys/mf_sort.c
index e7fd6873eee..741c8f42327 100644
--- a/mysys/mf_sort.c
+++ b/mysys/mf_sort.c
@@ -18,7 +18,7 @@
#include "mysys_priv.h"
#include <m_string.h>
-void my_string_ptr_sort(void *base, uint items, size_s size)
+void my_string_ptr_sort(uchar *base, uint items, size_t size)
{
#if INT_MAX > 65536L
uchar **ptr=0;
@@ -27,15 +27,15 @@ void my_string_ptr_sort(void *base, uint items, size_s size)
(ptr= (uchar**) my_malloc(items*sizeof(char*),MYF(0))))
{
radixsort_for_str_ptr((uchar**) base,items,size,ptr);
- my_free((gptr) ptr,MYF(0));
+ my_free((uchar*) ptr,MYF(0));
}
else
#endif
{
if (size && items)
{
- uint size_arg=size;
- qsort2(base,items,sizeof(byte*),get_ptr_compare(size),(void*) &size_arg);
+ qsort2(base,items, sizeof(uchar*), get_ptr_compare(size),
+ (void*) &size);
}
}
}
diff --git a/mysys/mf_soundex.c b/mysys/mf_soundex.c
index fa393d1a94a..fe30d8c81af 100644
--- a/mysys/mf_soundex.c
+++ b/mysys/mf_soundex.c
@@ -42,11 +42,11 @@ static char get_scode(CHARSET_INFO * cs, char **ptr,pbool remove_garbage);
/* outputed string is 4 byte long */
/* out_pntr can be == in_pntr */
-void soundex(CHARSET_INFO * cs,register my_string out_pntr, my_string in_pntr,
+void soundex(CHARSET_INFO * cs,register char * out_pntr, char * in_pntr,
pbool remove_garbage)
{
char ch,last_ch;
- reg3 my_string end;
+ reg3 char * end;
register uchar *map=cs->to_upper;
if (remove_garbage)
diff --git a/mysys/mf_strip.c b/mysys/mf_strip.c
index 712b0e1d28a..b33620b1b2d 100644
--- a/mysys/mf_strip.c
+++ b/mysys/mf_strip.c
@@ -18,14 +18,14 @@
#include "mysys_priv.h"
/*
- strip_sp(my_string str)
+ strip_sp(char * str)
Strips end-space from string and returns new length.
*/
-size_s strip_sp(register my_string str)
+size_t strip_sp(register char * str)
{
- reg2 my_string found;
- reg3 my_string start;
+ reg2 char * found;
+ reg3 char * start;
start=found=str;
@@ -35,11 +35,11 @@ size_s strip_sp(register my_string str)
{
while (*++str && *str != ' ') {};
if (!*str)
- return (size_s) (str-start); /* Return stringlength */
+ return (size_t) (str-start); /* Return stringlength */
}
found=str;
while (*++str == ' ') {};
}
*found= '\0'; /* Stripp at first space */
- return (size_s) (found-start);
+ return (size_t) (found-start);
} /* strip_sp */
diff --git a/mysys/mf_tempdir.c b/mysys/mf_tempdir.c
index 36eecbeac09..b2c18c74347 100644
--- a/mysys/mf_tempdir.c
+++ b/mysys/mf_tempdir.c
@@ -52,7 +52,7 @@ my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist)
strmake(buff, pathlist, (uint) (end-pathlist));
length= cleanup_dirname(buff, buff);
if (!(copy= my_strndup(buff, length, MYF(MY_WME))) ||
- insert_dynamic(&tmpdir->full_list, (gptr) &copy))
+ insert_dynamic(&tmpdir->full_list, (uchar*) &copy))
DBUG_RETURN(TRUE);
pathlist=end+1;
}
diff --git a/mysys/mf_unixpath.c b/mysys/mf_unixpath.c
index 11292e231ba..75f8de14879 100644
--- a/mysys/mf_unixpath.c
+++ b/mysys/mf_unixpath.c
@@ -19,7 +19,7 @@
/* convert filename to unix style filename */
/* If MSDOS converts '\' to '/' */
-void to_unix_path(my_string to __attribute__((unused)))
+void to_unix_path(char * to __attribute__((unused)))
{
#if FN_LIBCHAR != '/'
{
diff --git a/mysys/mf_wfile.c b/mysys/mf_wfile.c
index b574d158b9e..f98d348994e 100644
--- a/mysys/mf_wfile.c
+++ b/mysys/mf_wfile.c
@@ -29,12 +29,12 @@
/* Store wildcard-string in a easyer format */
-WF_PACK *wf_comp(my_string str)
+WF_PACK *wf_comp(char * str)
{
uint ant;
int not_pos;
- register my_string pos;
- my_string buffer;
+ register char * pos;
+ char * buffer;
WF_PACK *ret;
DBUG_ENTER("wf_comp");
@@ -53,13 +53,13 @@ WF_PACK *wf_comp(my_string str)
for (pos=str ; *pos ; pos++)
ant+= test(*pos == ' ' || *pos == ',');
- if ((ret= (WF_PACK*) my_malloc((uint) ant*(sizeof(my_string*)+2)+
+ if ((ret= (WF_PACK*) my_malloc((uint) ant*(sizeof(char **)+2)+
sizeof(WF_PACK)+ (uint) strlen(str)+1,
MYF(MY_WME)))
== 0)
DBUG_RETURN((WF_PACK *) NULL);
- ret->wild= (my_string*) (ret+1);
- buffer= (my_string) (ret->wild+ant);
+ ret->wild= (char **) (ret+1);
+ buffer= (char *) (ret->wild+ant);
ant=0;
for (pos=str ; *pos ; str= pos)
@@ -119,6 +119,6 @@ void wf_end(WF_PACK *buffer)
{
DBUG_ENTER("wf_end");
if (buffer)
- my_free((gptr) buffer,MYF(0));
+ my_free((uchar*) buffer,MYF(0));
DBUG_VOID_RETURN;
} /* wf_end */
diff --git a/mysys/mulalloc.c b/mysys/mulalloc.c
index bada0a55a6a..f4ca3d9f9ab 100644
--- a/mysys/mulalloc.c
+++ b/mysys/mulalloc.c
@@ -31,11 +31,11 @@
NULL
*/
-gptr my_multi_malloc(myf myFlags, ...)
+void* my_multi_malloc(myf myFlags, ...)
{
va_list args;
char **ptr,*start,*res;
- uint tot_length,length;
+ size_t tot_length,length;
DBUG_ENTER("my_multi_malloc");
va_start(args,myFlags);
@@ -59,5 +59,5 @@ gptr my_multi_malloc(myf myFlags, ...)
res+=ALIGN_SIZE(length);
}
va_end(args);
- DBUG_RETURN((gptr) start);
+ DBUG_RETURN((void*) start);
}
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index b4ebaeba647..9203ce9c34e 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -43,8 +43,8 @@
reported as error in first alloc_root() on this memory root.
*/
-void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
- uint pre_alloc_size __attribute__((unused)))
+void init_alloc_root(MEM_ROOT *mem_root, size_t block_size,
+ size_t pre_alloc_size __attribute__((unused)))
{
DBUG_ENTER("init_alloc_root");
DBUG_PRINT("enter",("root: 0x%lx", (long) mem_root));
@@ -90,8 +90,8 @@ void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
before allocation.
*/
-void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
- uint pre_alloc_size __attribute__((unused)))
+void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
+ size_t pre_alloc_size __attribute__((unused)))
{
DBUG_ASSERT(alloc_root_inited(mem_root));
@@ -99,7 +99,7 @@ void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
#if !(defined(HAVE_purify) && defined(EXTRA_DEBUG))
if (pre_alloc_size)
{
- uint size= pre_alloc_size + ALIGN_SIZE(sizeof(USED_MEM));
+ size_t size= pre_alloc_size + ALIGN_SIZE(sizeof(USED_MEM));
if (!mem_root->pre_alloc || mem_root->pre_alloc->size != size)
{
USED_MEM *mem, **prev= &mem_root->free;
@@ -120,7 +120,7 @@ void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
{
/* remove block from the list and free it */
*prev= mem->next;
- my_free((gptr) mem, MYF(0));
+ my_free(mem, MYF(0));
}
else
prev= &mem->next;
@@ -145,7 +145,7 @@ void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
}
-gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
+void *alloc_root(MEM_ROOT *mem_root, size_t length)
{
#if defined(HAVE_purify) && defined(EXTRA_DEBUG)
reg1 USED_MEM *next;
@@ -154,32 +154,32 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
DBUG_ASSERT(alloc_root_inited(mem_root));
- Size+=ALIGN_SIZE(sizeof(USED_MEM));
- if (!(next = (USED_MEM*) my_malloc(Size,MYF(MY_WME))))
+ length+=ALIGN_SIZE(sizeof(USED_MEM));
+ if (!(next = (USED_MEM*) my_malloc(length,MYF(MY_WME))))
{
if (mem_root->error_handler)
(*mem_root->error_handler)();
- DBUG_RETURN((gptr) 0); /* purecov: inspected */
+ DBUG_RETURN((uchar*) 0); /* purecov: inspected */
}
next->next= mem_root->used;
- next->size= Size;
+ next->size= length;
mem_root->used= next;
DBUG_PRINT("exit",("ptr: 0x%lx", (long) (((char*) next)+
ALIGN_SIZE(sizeof(USED_MEM)))));
- DBUG_RETURN((gptr) (((char*) next)+ALIGN_SIZE(sizeof(USED_MEM))));
+ DBUG_RETURN((uchar*) (((char*) next)+ALIGN_SIZE(sizeof(USED_MEM))));
#else
- uint get_size, block_size;
- gptr point;
+ size_t get_size, block_size;
+ uchar* point;
reg1 USED_MEM *next= 0;
reg2 USED_MEM **prev;
DBUG_ENTER("alloc_root");
DBUG_PRINT("enter",("root: 0x%lx", (long) mem_root));
DBUG_ASSERT(alloc_root_inited(mem_root));
- Size= ALIGN_SIZE(Size);
+ length= ALIGN_SIZE(length);
if ((*(prev= &mem_root->free)) != NULL)
{
- if ((*prev)->left < Size &&
+ if ((*prev)->left < length &&
mem_root->first_block_usage++ >= ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP &&
(*prev)->left < ALLOC_MAX_BLOCK_TO_DROP)
{
@@ -189,20 +189,20 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
mem_root->used= next;
mem_root->first_block_usage= 0;
}
- for (next= *prev ; next && next->left < Size ; next= next->next)
+ for (next= *prev ; next && next->left < length ; next= next->next)
prev= &next->next;
}
if (! next)
{ /* Time to alloc new block */
block_size= mem_root->block_size * (mem_root->block_num >> 2);
- get_size= Size+ALIGN_SIZE(sizeof(USED_MEM));
+ get_size= length+ALIGN_SIZE(sizeof(USED_MEM));
get_size= max(get_size, block_size);
if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME))))
{
if (mem_root->error_handler)
(*mem_root->error_handler)();
- return((gptr) 0); /* purecov: inspected */
+ return((void*) 0); /* purecov: inspected */
}
mem_root->block_num++;
next->next= *prev;
@@ -211,9 +211,9 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
*prev=next;
}
- point= (gptr) ((char*) next+ (next->size-next->left));
+ point= (uchar*) ((char*) next+ (next->size-next->left));
/*TODO: next part may be unneded due to mem_root->first_block_usage counter*/
- if ((next->left-= Size) < mem_root->min_malloc)
+ if ((next->left-= length) < mem_root->min_malloc)
{ /* Full block */
*prev= next->next; /* Remove block from list */
next->next= mem_root->used;
@@ -221,7 +221,7 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
mem_root->first_block_usage= 0;
}
DBUG_PRINT("exit",("ptr: 0x%lx", (ulong) point));
- DBUG_RETURN(point);
+ DBUG_RETURN((void*) point);
#endif
}
@@ -245,11 +245,11 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
in case of success or NULL if out of memory.
*/
-gptr multi_alloc_root(MEM_ROOT *root, ...)
+void *multi_alloc_root(MEM_ROOT *root, ...)
{
va_list args;
char **ptr, *start, *res;
- uint tot_length, length;
+ size_t tot_length, length;
DBUG_ENTER("multi_alloc_root");
va_start(args, root);
@@ -273,7 +273,7 @@ gptr multi_alloc_root(MEM_ROOT *root, ...)
res+= ALIGN_SIZE(length);
}
va_end(args);
- DBUG_RETURN((gptr) start);
+ DBUG_RETURN((void*) start);
}
#define TRASH_MEM(X) TRASH(((char*)(X) + ((X)->size-(X)->left)), (X)->left)
@@ -346,13 +346,13 @@ void free_root(MEM_ROOT *root, myf MyFlags)
{
old=next; next= next->next ;
if (old != root->pre_alloc)
- my_free((gptr) old,MYF(0));
+ my_free(old,MYF(0));
}
for (next=root->free ; next ;)
{
old=next; next= next->next;
if (old != root->pre_alloc)
- my_free((gptr) old,MYF(0));
+ my_free(old,MYF(0));
}
root->used=root->free=0;
if (root->pre_alloc)
@@ -393,13 +393,13 @@ void set_prealloc_root(MEM_ROOT *root, char *ptr)
}
-char *strdup_root(MEM_ROOT *root,const char *str)
+char *strdup_root(MEM_ROOT *root, const char *str)
{
- return strmake_root(root, str, (uint) strlen(str));
+ return strmake_root(root, str, strlen(str));
}
-char *strmake_root(MEM_ROOT *root,const char *str, uint len)
+char *strmake_root(MEM_ROOT *root, const char *str, size_t len)
{
char *pos;
if ((pos=alloc_root(root,len+1)))
@@ -411,7 +411,7 @@ char *strmake_root(MEM_ROOT *root,const char *str, uint len)
}
-char *memdup_root(MEM_ROOT *root,const char *str,uint len)
+void *memdup_root(MEM_ROOT *root, const void *str, size_t len)
{
char *pos;
if ((pos=alloc_root(root,len)))
diff --git a/mysys/my_chsize.c b/mysys/my_chsize.c
index a5dd1564692..b1dbb22c687 100644
--- a/mysys/my_chsize.c
+++ b/mysys/my_chsize.c
@@ -40,12 +40,12 @@
int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags)
{
my_off_t oldsize;
- char buff[IO_SIZE];
+ uchar buff[IO_SIZE];
DBUG_ENTER("my_chsize");
DBUG_PRINT("my",("fd: %d length: %lu MyFlags: %d",fd,(ulong) newlength,
MyFlags));
- if ((oldsize = my_seek(fd, 0L, MY_SEEK_END, MYF(MY_WME+MY_FAE))) == newlength)
+ if ((oldsize= my_seek(fd, 0L, MY_SEEK_END, MYF(MY_WME+MY_FAE))) == newlength)
DBUG_RETURN(0);
DBUG_PRINT("info",("old_size: %ld", (ulong) oldsize));
@@ -98,11 +98,11 @@ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags)
bfill(buff, IO_SIZE, filler);
while (newlength-oldsize > IO_SIZE)
{
- if (my_write(fd,(byte*) buff,IO_SIZE,MYF(MY_NABP)))
+ if (my_write(fd, buff, IO_SIZE, MYF(MY_NABP)))
goto err;
oldsize+= IO_SIZE;
}
- if (my_write(fd,(byte*) buff,(uint) (newlength-oldsize),MYF(MY_NABP)))
+ if (my_write(fd,buff,(size_t) (newlength-oldsize), MYF(MY_NABP)))
goto err;
DBUG_RETURN(0);
diff --git a/mysys/my_compress.c b/mysys/my_compress.c
index 45e60552592..3966be8b6bb 100644
--- a/mysys/my_compress.c
+++ b/mysys/my_compress.c
@@ -24,12 +24,20 @@
#include <zlib.h>
/*
-** This replaces the packet with a compressed packet
-** Returns 1 on error
-** *complen is 0 if the packet wasn't compressed
+ This replaces the packet with a compressed packet
+
+ SYNOPSIS
+ my_compress()
+ packet Data to compress. This is is replaced with the compressed data.
+ len Length of data to compress at 'packet'
+ complen out: 0 if packet was not compressed
+
+ RETURN
+ 1 error. 'len' is not changed'
+ 0 ok. In this case 'len' contains the size of the compressed packet
*/
-my_bool my_compress(byte *packet, ulong *len, ulong *complen)
+my_bool my_compress(uchar *packet, size_t *len, size_t *complen)
{
DBUG_ENTER("my_compress");
if (*len < MIN_COMPRESS_LENGTH)
@@ -39,27 +47,36 @@ my_bool my_compress(byte *packet, ulong *len, ulong *complen)
}
else
{
- byte *compbuf=my_compress_alloc(packet,len,complen);
+ uchar *compbuf=my_compress_alloc(packet,len,complen);
if (!compbuf)
DBUG_RETURN(*complen ? 0 : 1);
memcpy(packet,compbuf,*len);
- my_free(compbuf,MYF(MY_WME)); }
+ my_free(compbuf,MYF(MY_WME));
+ }
DBUG_RETURN(0);
}
-byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen)
+uchar *my_compress_alloc(const uchar *packet, size_t *len, size_t *complen)
{
- byte *compbuf;
+ uchar *compbuf;
+ uLongf tmp_complen;
+ int res;
*complen= *len * 120 / 100 + 12;
- if (!(compbuf= (byte *) my_malloc(*complen,MYF(MY_WME))))
+
+ if (!(compbuf= (uchar *) my_malloc(*complen, MYF(MY_WME))))
return 0; /* Not enough memory */
- if (compress((Bytef*) compbuf,(ulong *) complen, (Bytef*) packet,
- (uLong) *len ) != Z_OK)
+
+ tmp_complen= *complen;
+ res= compress((Bytef*) compbuf, &tmp_complen, (Bytef*) packet, *len);
+ *complen= tmp_complen;
+
+ if (res != Z_OK)
{
- my_free(compbuf,MYF(MY_WME));
+ my_free(compbuf, MYF(MY_WME));
return 0;
}
+
if (*complen >= *len)
{
*complen= 0;
@@ -67,50 +84,68 @@ byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen)
DBUG_PRINT("note",("Packet got longer on compression; Not compressed"));
return 0;
}
- swap_variables(ulong, *len, *complen); /* *len is now packet length */
+ /* Store length of compressed packet in *len */
+ swap_variables(size_t, *len, *complen);
return compbuf;
}
-my_bool my_uncompress (byte *packet, ulong *len, ulong *complen)
+/*
+ Uncompress packet
+
+ SYNOPSIS
+ my_uncompress()
+ packet Compressed data. This is is replaced with the orignal data.
+ len Length of compressed data
+ complen Length of the packet buffer (must be enough for the original
+ data)
+
+ RETURN
+ 1 error
+ 0 ok. In this case 'complen' contains the updated size of the
+ real data.
+*/
+
+my_bool my_uncompress(uchar *packet, size_t len, size_t *complen)
{
+ uLongf tmp_complen;
DBUG_ENTER("my_uncompress");
+
if (*complen) /* If compressed */
{
- byte *compbuf= (byte *) my_malloc(*complen,MYF(MY_WME));
+ uchar *compbuf= (uchar *) my_malloc(*complen,MYF(MY_WME));
int error;
if (!compbuf)
DBUG_RETURN(1); /* Not enough memory */
- if ((error=uncompress((Bytef*) compbuf, complen, (Bytef*) packet, *len))
- != Z_OK)
+
+ tmp_complen= *complen;
+ error= uncompress((Bytef*) compbuf, &tmp_complen, (Bytef*) packet,
+ len);
+ *complen= tmp_complen;
+ if (error != Z_OK)
{ /* Probably wrong packet */
DBUG_PRINT("error",("Can't uncompress packet, error: %d",error));
my_free(compbuf, MYF(MY_WME));
DBUG_RETURN(1);
}
- *len= *complen;
- memcpy(packet, compbuf, *len);
+ memcpy(packet, compbuf, *complen);
my_free(compbuf, MYF(MY_WME));
}
+ else
+ *complen= len;
DBUG_RETURN(0);
}
/*
- Internal representation of the frm blob
+ Internal representation of the frm blob is:
+
+ ver 4 bytes
+ orglen 4 bytes
+ complen 4 bytes
*/
-struct frm_blob_header
-{
- uint ver; /* Version of header */
- uint orglen; /* Original length of compressed data */
- uint complen; /* Compressed length of data, 0=uncompressed */
-};
+#define BLOB_HEADER 12
-struct frm_blob_struct
-{
- struct frm_blob_header head;
- char data[1];
-};
/*
packfrm is a method used to compress the frm file for storage in a
@@ -129,43 +164,42 @@ struct frm_blob_struct
>0 Failure
*/
-int packfrm(const void *data, uint len,
- const void **pack_data, uint *pack_len)
+int packfrm(const uchar *data, size_t len,
+ uchar **pack_data, size_t *pack_len)
{
int error;
- ulong org_len, comp_len;
- uint blob_len;
- struct frm_blob_struct *blob;
+ size_t org_len, comp_len, blob_len;
+ uchar *blob;
DBUG_ENTER("packfrm");
- DBUG_PRINT("enter", ("data: 0x%lx, len: %d", (long) data, len));
+ DBUG_PRINT("enter", ("data: 0x%lx len: %lu", (long) data, (ulong) len));
error= 1;
org_len= len;
- if (my_compress((byte*)data, &org_len, &comp_len))
+ if (my_compress((uchar*)data, &org_len, &comp_len))
goto err;
DBUG_PRINT("info", ("org_len: %lu comp_len: %lu", org_len, comp_len));
DBUG_DUMP("compressed", (char*)data, org_len);
error= 2;
- blob_len= sizeof(struct frm_blob_header)+org_len;
- if (!(blob= (struct frm_blob_struct*) my_malloc(blob_len,MYF(MY_WME))))
+ blob_len= BLOB_HEADER + org_len;
+ if (!(blob= (uchar*) my_malloc(blob_len,MYF(MY_WME))))
goto err;
/* Store compressed blob in machine independent format */
- int4store((char*)(&blob->head.ver), 1);
- int4store((char*)(&blob->head.orglen), comp_len);
- int4store((char*)(&blob->head.complen), org_len);
+ int4store(blob, 1);
+ int4store(blob+4, (uint32) len);
+ int4store(blob+8, (uint32) org_len); /* compressed length */
/* Copy frm data into blob, already in machine independent format */
- memcpy(blob->data, data, org_len);
+ memcpy(blob+BLOB_HEADER, data, org_len);
*pack_data= blob;
- *pack_len= blob_len;
+ *pack_len= blob_len;
error= 0;
- DBUG_PRINT("exit", ("pack_data: 0x%lx pack_len: %d",
- (long) *pack_data, *pack_len));
+ DBUG_PRINT("exit", ("pack_data: 0x%lx pack_len: %lu",
+ (long) *pack_data, (ulong) *pack_len));
err:
DBUG_RETURN(error);
@@ -187,40 +221,40 @@ err:
>0 Failure
*/
-int unpackfrm(const void **unpack_data, uint *unpack_len,
- const void *pack_data)
+int unpackfrm(uchar **unpack_data, size_t *unpack_len,
+ const uchar *pack_data)
{
- const struct frm_blob_struct *blob= (struct frm_blob_struct*)pack_data;
- byte *data;
- ulong complen, orglen, ver;
+ uchar *data;
+ size_t complen, orglen;
+ ulong ver;
DBUG_ENTER("unpackfrm");
DBUG_PRINT("enter", ("pack_data: 0x%lx", (long) pack_data));
- complen= uint4korr((char*)&blob->head.complen);
- orglen= uint4korr((char*)&blob->head.orglen);
- ver= uint4korr((char*)&blob->head.ver);
+ ver= uint4korr(pack_data);
+ orglen= uint4korr(pack_data+4);
+ complen= uint4korr(pack_data+8);
DBUG_PRINT("blob",("ver: %lu complen: %lu orglen: %lu",
- ver,complen,orglen));
- DBUG_DUMP("blob->data", (char*) blob->data, complen);
+ ver, complen, orglen));
+ DBUG_DUMP("blob->data", pack_data + BLOB_HEADER, complen);
if (ver != 1)
DBUG_RETURN(1);
if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME))))
DBUG_RETURN(2);
- memcpy(data, blob->data, complen);
-
+ memcpy(data, pack_data + BLOB_HEADER, complen);
- if (my_uncompress(data, &complen, &orglen))
+ if (my_uncompress(data, complen, &orglen))
{
- my_free((char*)data, MYF(0));
+ my_free(data, MYF(0));
DBUG_RETURN(3);
}
*unpack_data= data;
- *unpack_len= complen;
+ *unpack_len= orglen;
- DBUG_PRINT("exit", ("frmdata: 0x%lx len: %d", (long) *unpack_data, *unpack_len));
+ DBUG_PRINT("exit", ("frmdata: 0x%lx len: %lu", (long) *unpack_data,
+ (ulong) *unpack_len));
DBUG_RETURN(0);
}
#endif /* HAVE_COMPRESS */
diff --git a/mysys/my_conio.c b/mysys/my_conio.c
index 23b0c55e7a9..d03f63a11a9 100644
--- a/mysys/my_conio.c
+++ b/mysys/my_conio.c
@@ -29,10 +29,10 @@ static HANDLE my_coninpfh= 0; /* console input */
if found useful they are to be exported in mysys
*/
+
/*
int my_pthread_auto_mutex_lock(HANDLE* ph, const char* name,
int id, int time)
-
NOTES
creates a mutex with given name and tries to lock it time msec.
mutex name is appended with id to allow system wide or process wide
@@ -41,8 +41,8 @@ static HANDLE my_coninpfh= 0; /* console input */
RETURN
0 thread owns mutex
<>0 error
-
*/
+
static
int my_pthread_auto_mutex_lock(HANDLE* ph, const char* name, int id, int time)
{
@@ -69,7 +69,6 @@ int my_pthread_auto_mutex_lock(HANDLE* ph, const char* name, int id, int time)
/*
int my_pthread_auto_mutex_free(HANDLE* ph)
-
NOTES
releases a mutex.
@@ -103,7 +102,7 @@ int my_pthread_auto_mutex_free(HANDLE* ph)
/*
- char* my_cgets(char *string, unsigned long clen, unsigned long* plen)
+ char* my_cgets()
NOTES
Replaces _cgets from libc to support input of more than 255 chars.
@@ -121,7 +120,8 @@ int my_pthread_auto_mutex_free(HANDLE* ph)
NULL Error
*/
-char* my_cgets(char *buffer, unsigned long clen, unsigned long* plen)
+
+char* my_cgets(char *buffer, size_t clen, size_t* plen)
{
ULONG state;
char *result;
@@ -170,7 +170,7 @@ char* my_cgets(char *buffer, unsigned long clen, unsigned long* plen)
clen= min(clen, 65535);
do
{
- clen= min(clen, (unsigned long)csbi.dwSize.X*csbi.dwSize.Y);
+ clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, clen - 1, plen, NULL))
{
result= NULL;
diff --git a/mysys/my_create.c b/mysys/my_create.c
index 5639459f5a9..55878318ead 100644
--- a/mysys/my_create.c
+++ b/mysys/my_create.c
@@ -40,13 +40,13 @@ File my_create(const char *FileName, int CreateFlags, int access_flags,
FileName, CreateFlags, access_flags, MyFlags));
#if !defined(NO_OPEN_3)
- fd = open((my_string) FileName, access_flags | O_CREAT,
+ fd = open((char *) FileName, access_flags | O_CREAT,
CreateFlags ? CreateFlags : my_umask);
#elif defined(VMS)
- fd = open((my_string) FileName, access_flags | O_CREAT, 0,
+ fd = open((char *) FileName, access_flags | O_CREAT, 0,
"ctx=stm","ctx=bin");
#elif defined(__WIN__)
- fd= my_sopen((my_string) FileName, access_flags | O_CREAT | O_BINARY,
+ fd= my_sopen((char *) FileName, access_flags | O_CREAT | O_BINARY,
SH_DENYNO, MY_S_IREAD | MY_S_IWRITE);
#else
fd = open(FileName, access_flags);
diff --git a/mysys/my_div.c b/mysys/my_div.c
index 656c6cfde91..d29d3668852 100644
--- a/mysys/my_div.c
+++ b/mysys/my_div.c
@@ -23,7 +23,7 @@
fd File descriptor
*/
-my_string my_filename(File fd)
+char * my_filename(File fd)
{
DBUG_ENTER("my_filename");
if ((uint) fd >= (uint) my_file_limit)
diff --git a/mysys/my_error.c b/mysys/my_error.c
index 48392fe84c3..e8fd8b938ee 100644
--- a/mysys/my_error.c
+++ b/mysys/my_error.c
@@ -191,7 +191,7 @@ int my_error_register(const char **errmsgs, int first, int last)
/* Error numbers must be unique. No overlapping is allowed. */
if (*search_meh_pp && ((*search_meh_pp)->meh_first <= last))
{
- my_free((gptr)meh_p, MYF(0));
+ my_free((uchar*)meh_p, MYF(0));
return 1;
}
@@ -247,7 +247,7 @@ const char **my_error_unregister(int first, int last)
/* Save the return value and free the header. */
errmsgs= meh_p->meh_errmsgs;
- my_free((gptr) meh_p, MYF(0));
+ my_free((uchar*) meh_p, MYF(0));
return errmsgs;
}
@@ -259,7 +259,7 @@ void my_error_unregister_all(void)
for (list= my_errmsgs_globerrs.meh_next; list; list= next)
{
next= list->meh_next;
- my_free((gptr) list, MYF(0));
+ my_free((uchar*) list, MYF(0));
}
my_errmsgs_list= &my_errmsgs_globerrs;
}
diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c
index b56be263ba4..09f710c1ef4 100644
--- a/mysys/my_fopen.c
+++ b/mysys/my_fopen.c
@@ -18,7 +18,7 @@
#include <errno.h>
#include "mysys_err.h"
-static void make_ftype(my_string to,int flag);
+static void make_ftype(char * to,int flag);
/*
Open a file as stream
@@ -192,7 +192,7 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags)
a+ == O_RDWR|O_APPEND|O_CREAT
*/
-static void make_ftype(register my_string to, register int flag)
+static void make_ftype(register char * to, register int flag)
{
/* check some possible invalid combinations */
DBUG_ASSERT((flag & (O_TRUNC | O_APPEND)) != (O_TRUNC | O_APPEND));
diff --git a/mysys/my_fstream.c b/mysys/my_fstream.c
index ea30509ca8c..f5fe862937c 100644
--- a/mysys/my_fstream.c
+++ b/mysys/my_fstream.c
@@ -27,24 +27,31 @@
#define fseek(A,B,C) fseeko((A),(B),(C))
#endif
- /* Read a chunk of bytes from a file */
- /* Returns (uint) -1 if error as my_read() */
-
-uint my_fread(FILE *stream, byte *Buffer, uint Count, myf MyFlags)
- /* File descriptor */
- /* Buffer must be at least count bytes */
- /* Max number of bytes returnd */
- /* Flags on what to do on error */
+/*
+ Read a chunk of bytes from a FILE
+
+ SYNOPSIS
+ my_fread()
+ stream File descriptor
+ Buffer Buffer to read to
+ Count Number of bytes to read
+ MyFlags Flags on what to do on error
+
+ RETURN
+ (size_t) -1 Error
+ # Number of bytes read
+ */
+
+size_t my_fread(FILE *stream, uchar *Buffer, size_t Count, myf MyFlags)
{
- uint readbytes;
+ size_t readbytes;
DBUG_ENTER("my_fread");
DBUG_PRINT("my",("stream: 0x%lx Buffer: 0x%lx Count: %u MyFlags: %d",
- (long) stream, (long) Buffer, Count, MyFlags));
+ (long) stream, (long) Buffer, (uint) Count, MyFlags));
- if ((readbytes = (uint) fread(Buffer,sizeof(char),(size_t) Count,stream))
- != Count)
+ if ((readbytes= fread(Buffer, sizeof(char), Count, stream)) != Count)
{
- DBUG_PRINT("error",("Read only %d bytes",readbytes));
+ DBUG_PRINT("error",("Read only %d bytes", (int) readbytes));
if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
{
if (ferror(stream))
@@ -57,7 +64,7 @@ uint my_fread(FILE *stream, byte *Buffer, uint Count, myf MyFlags)
}
my_errno=errno ? errno : -1;
if (ferror(stream) || MyFlags & (MY_NABP | MY_FNABP))
- DBUG_RETURN((uint) -1); /* Return with error */
+ DBUG_RETURN((size_t) -1); /* Return with error */
}
if (MyFlags & (MY_NABP | MY_FNABP))
DBUG_RETURN(0); /* Read ok */
@@ -66,40 +73,48 @@ uint my_fread(FILE *stream, byte *Buffer, uint Count, myf MyFlags)
/*
-** Write a chunk of bytes to a stream
-** Returns (uint) -1 if error as my_write()
-** Does retries if interrupted
+ Write a chunk of bytes to a stream
+
+ my_fwrite()
+ stream File descriptor
+ Buffer Buffer to write from
+ Count Number of bytes to write
+ MyFlags Flags on what to do on error
+
+ RETURN
+ (size_t) -1 Error
+ # Number of bytes written
*/
-uint my_fwrite(FILE *stream, const byte *Buffer, uint Count, myf MyFlags)
+size_t my_fwrite(FILE *stream, const uchar *Buffer, size_t Count, myf MyFlags)
{
- uint writenbytes=0;
- off_t seekptr;
+ size_t writtenbytes =0;
+ my_off_t seekptr;
#if !defined(NO_BACKGROUND) && defined(USE_MY_STREAM)
uint errors;
#endif
DBUG_ENTER("my_fwrite");
DBUG_PRINT("my",("stream: 0x%lx Buffer: 0x%lx Count: %u MyFlags: %d",
- (long) stream, (long) Buffer, Count, MyFlags));
+ (long) stream, (long) Buffer, (uint) Count, MyFlags));
#if !defined(NO_BACKGROUND) && defined(USE_MY_STREAM)
errors=0;
#endif
- seekptr=ftell(stream);
+ seekptr= ftell(stream);
for (;;)
{
- uint writen;
- if ((writen = (uint) fwrite((char*) Buffer,sizeof(char),
- (size_t) Count, stream)) != Count)
+ size_t written;
+ if ((written = (size_t) fwrite((char*) Buffer,sizeof(char),
+ Count, stream)) != Count)
{
- DBUG_PRINT("error",("Write only %d bytes",writenbytes));
+ DBUG_PRINT("error",("Write only %d bytes", (int) writtenbytes));
my_errno=errno;
- if (writen != (uint) -1)
+ if (written != (size_t) -1)
{
- seekptr+=writen;
- Buffer+=writen;
- writenbytes+=writen;
- Count-=writen;
+ seekptr+=written;
+ Buffer+=written;
+ writtenbytes+=written;
+ Count-=written;
}
#ifdef EINTR
if (errno == EINTR)
@@ -131,21 +146,21 @@ uint my_fwrite(FILE *stream, const byte *Buffer, uint Count, myf MyFlags)
my_error(EE_WRITE, MYF(ME_BELL+ME_WAITTANG),
my_filename(fileno(stream)),errno);
}
- writenbytes=(uint) -1; /* Return that we got error */
+ writtenbytes= (size_t) -1; /* Return that we got error */
break;
}
}
if (MyFlags & (MY_NABP | MY_FNABP))
- writenbytes=0; /* Everything OK */
+ writtenbytes= 0; /* Everything OK */
else
- writenbytes+=writen;
+ writtenbytes+= written;
break;
}
- DBUG_RETURN(writenbytes);
+ DBUG_RETURN(writtenbytes);
} /* my_fwrite */
- /* Seek to position in file */
- /* ARGSUSED */
+
+/* Seek to position in file */
my_off_t my_fseek(FILE *stream, my_off_t pos, int whence,
myf MyFlags __attribute__((unused)))
@@ -158,8 +173,7 @@ my_off_t my_fseek(FILE *stream, my_off_t pos, int whence,
} /* my_seek */
- /* Tell current position of file */
- /* ARGSUSED */
+/* Tell current position of file */
my_off_t my_ftell(FILE *stream, myf MyFlags __attribute__((unused)))
{
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index aa470282aa4..ecb740a15c7 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -33,7 +33,7 @@ static longlong getopt_ll(char *arg, const struct my_option *optp, int *err);
static ulonglong getopt_ull(char *arg, const struct my_option *optp,
int *err);
static void init_variables(const struct my_option *options);
-static int setval(const struct my_option *opts, gptr *value, char *argument,
+static int setval(const struct my_option *opts, uchar* *value, char *argument,
my_bool set_maximum_value);
static char *check_struct_option(char *cur_arg, char *key_name);
@@ -82,9 +82,9 @@ static void default_reporter(enum loglevel level,
one. Call function 'get_one_option()' once for each option.
*/
-static gptr* (*getopt_get_addr)(const char *, uint, const struct my_option *);
+static uchar** (*getopt_get_addr)(const char *, uint, const struct my_option *);
-void my_getopt_register_get_addr(gptr* (*func_addr)(const char *, uint,
+void my_getopt_register_get_addr(uchar** (*func_addr)(const char *, uint,
const struct my_option *))
{
getopt_get_addr= func_addr;
@@ -100,7 +100,7 @@ int handle_options(int *argc, char ***argv,
char **pos, **pos_end, *optend, *prev_found,
*opt_str, key_name[FN_REFLEN];
const struct my_option *optp;
- gptr *value;
+ uchar* *value;
int error;
LINT_INIT(opt_found);
@@ -556,14 +556,14 @@ static char *check_struct_option(char *cur_arg, char *key_name)
Will set the option value to given value
*/
-static int setval(const struct my_option *opts, gptr *value, char *argument,
+static int setval(const struct my_option *opts, uchar* *value, char *argument,
my_bool set_maximum_value)
{
int err= 0;
if (value && argument)
{
- gptr *result_pos= ((set_maximum_value) ?
+ uchar* *result_pos= ((set_maximum_value) ?
opts->u_max_value : value);
if (!result_pos)
@@ -777,7 +777,7 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp)
value Pointer to variable
*/
-static void init_one_value(const struct my_option *option, gptr *variable,
+static void init_one_value(const struct my_option *option, uchar* *variable,
longlong value)
{
switch ((option->var_type & GET_TYPE_MASK)) {
@@ -825,7 +825,7 @@ static void init_variables(const struct my_option *options)
{
for (; options->name; options++)
{
- gptr *variable;
+ uchar* *variable;
/*
We must set u_max_value first as for some variables
options->u_max_value == options->value and in this case we want to
@@ -937,7 +937,7 @@ void my_print_variables(const struct my_option *options)
printf("--------------------------------- -----------------------------\n");
for (optp= options; optp->id; optp++)
{
- gptr *value= (optp->var_type & GET_ASK_ADDR ?
+ uchar* *value= (optp->var_type & GET_ASK_ADDR ?
(*getopt_get_addr)("", 0, optp) : optp->value);
if (value)
{
diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c
index c258db8b126..cbfebcf2374 100644
--- a/mysys/my_getwd.c
+++ b/mysys/my_getwd.c
@@ -27,16 +27,28 @@
#include <direct.h>
#endif
- /* Gets current working directory in buff. Directory is allways ended
- with FN_LIBCHAR */
- /* One must pass a buffer to my_getwd. One can allways use
- curr_dir[] */
+/* Gets current working directory in buff.
-int my_getwd(my_string buf, uint size, myf MyFlags)
+ SYNPOSIS
+ my_getwd()
+ buf Buffer to store result. Can be curr_dir[].
+ size Size of buffer
+ MyFlags Flags
+
+ NOTES
+ Directory is allways ended with FN_LIBCHAR
+
+ RESULT
+ 0 ok
+ # error
+*/
+
+int my_getwd(char * buf, size_t size, myf MyFlags)
{
- my_string pos;
+ char * pos;
DBUG_ENTER("my_getwd");
- DBUG_PRINT("my",("buf: 0x%lx size: %d MyFlags %d", (long) buf,size,MyFlags));
+ DBUG_PRINT("my",("buf: 0x%lx size: %u MyFlags %d",
+ (long) buf, (uint) size, MyFlags));
if (curr_dir[0]) /* Current pos is saved here */
VOID(strmake(buf,&curr_dir[0],size-1));
@@ -71,26 +83,26 @@ int my_getwd(my_string buf, uint size, myf MyFlags)
pos[0]= FN_LIBCHAR;
pos[1]=0;
}
- (void) strmake(&curr_dir[0],buf,(size_s) (FN_REFLEN-1));
+ (void) strmake(&curr_dir[0],buf, (size_t) (FN_REFLEN-1));
}
DBUG_RETURN(0);
} /* my_getwd */
- /* Set new working directory */
+/* Set new working directory */
int my_setwd(const char *dir, myf MyFlags)
{
int res;
- size_s length;
- my_string start,pos;
+ size_t length;
+ char *start, *pos;
#if defined(VMS)
char buff[FN_REFLEN];
#endif
DBUG_ENTER("my_setwd");
DBUG_PRINT("my",("dir: '%s' MyFlags %d", dir, MyFlags));
- start=(my_string) dir;
+ start=(char *) dir;
if (! dir[0] || (dir[0] == FN_LIBCHAR && dir[1] == 0))
dir=FN_ROOTDIR;
#ifdef VMS
@@ -115,7 +127,7 @@ int my_setwd(const char *dir, myf MyFlags)
{
if (test_if_hard_path(start))
{ /* Hard pathname */
- pos=strmake(&curr_dir[0],start,(size_s) FN_REFLEN-1);
+ pos= strmake(&curr_dir[0],start,(size_t) FN_REFLEN-1);
if (pos[-1] != FN_LIBCHAR)
{
length=(uint) (pos-(char*) curr_dir);
diff --git a/mysys/my_init.c b/mysys/my_init.c
index 7784c09d9d6..dcc49c68c0f 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -69,7 +69,7 @@ static ulong atoi_octal(const char *str)
my_bool my_init(void)
{
- my_string str;
+ char * str;
if (my_init_done)
return 0;
my_init_done=1;
diff --git a/mysys/my_largepage.c b/mysys/my_largepage.c
index 9714c582acb..a20111396cb 100644
--- a/mysys/my_largepage.c
+++ b/mysys/my_largepage.c
@@ -26,8 +26,8 @@
#endif
static uint my_get_large_page_size_int(void);
-static gptr my_large_malloc_int(uint size, myf my_flags);
-static my_bool my_large_free_int(gptr ptr, myf my_flags);
+static uchar* my_large_malloc_int(size_t size, myf my_flags);
+static my_bool my_large_free_int(uchar* ptr, myf my_flags);
/* Gets the size of large pages from the OS */
@@ -48,9 +48,9 @@ uint my_get_large_page_size(void)
my_malloc_lock() in case of failure
*/
-gptr my_large_malloc(uint size, myf my_flags)
+uchar* my_large_malloc(size_t size, myf my_flags)
{
- gptr ptr;
+ uchar* ptr;
DBUG_ENTER("my_large_malloc");
if (my_use_large_pages && my_large_page_size)
@@ -70,7 +70,7 @@ gptr my_large_malloc(uint size, myf my_flags)
to my_free_lock() in case of failure
*/
-void my_large_free(gptr ptr, myf my_flags __attribute__((unused)))
+void my_large_free(uchar* ptr, myf my_flags __attribute__((unused)))
{
DBUG_ENTER("my_large_free");
@@ -113,29 +113,29 @@ finish:
#if HAVE_DECL_SHM_HUGETLB
/* Linux-specific large pages allocator */
-gptr my_large_malloc_int(uint size, myf my_flags)
+uchar* my_large_malloc_int(size_t size, myf my_flags)
{
int shmid;
- gptr ptr;
+ uchar* ptr;
struct shmid_ds buf;
DBUG_ENTER("my_large_malloc_int");
/* Align block size to my_large_page_size */
size = ((size - 1) & ~(my_large_page_size - 1)) + my_large_page_size;
- shmid = shmget(IPC_PRIVATE, (size_t)size, SHM_HUGETLB | SHM_R | SHM_W);
+ shmid = shmget(IPC_PRIVATE, size, SHM_HUGETLB | SHM_R | SHM_W);
if (shmid < 0)
{
if (my_flags & MY_WME)
fprintf(stderr,
- "Warning: Failed to allocate %d bytes from HugeTLB memory."
- " errno %d\n", size, errno);
+ "Warning: Failed to allocate %lu bytesx from HugeTLB memory."
+ " errno %d\n", (ulong) size, errno);
DBUG_RETURN(NULL);
}
- ptr = shmat(shmid, NULL, 0);
- if (ptr == (void *)-1)
+ ptr = (uchar*) shmat(shmid, NULL, 0);
+ if (ptr == (uchar *) -1)
{
if (my_flags& MY_WME)
fprintf(stderr, "Warning: Failed to attach shared memory segment,"
@@ -156,7 +156,7 @@ gptr my_large_malloc_int(uint size, myf my_flags)
/* Linux-specific large pages deallocator */
-my_bool my_large_free_int(byte *ptr, myf my_flags __attribute__((unused)))
+my_bool my_large_free_int(uchar *ptr, myf my_flags __attribute__((unused)))
{
DBUG_ENTER("my_large_free_int");
DBUG_RETURN(shmdt(ptr) == 0);
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index 783a0683731..c10b2e391b4 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -78,7 +78,7 @@ void my_dirend(MY_DIR *buffer)
ALIGN_SIZE(sizeof(MY_DIR))));
free_root((MEM_ROOT*)((char*)buffer + ALIGN_SIZE(sizeof(MY_DIR)) +
ALIGN_SIZE(sizeof(DYNAMIC_ARRAY))), MYF(0));
- my_free((gptr) buffer,MYF(0));
+ my_free((uchar*) buffer,MYF(0));
}
DBUG_VOID_RETURN;
} /* my_dirend */
@@ -114,7 +114,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
pthread_mutex_lock(&THR_LOCK_open);
#endif
- dirp = opendir(directory_file_name(tmp_path,(my_string) path));
+ dirp = opendir(directory_file_name(tmp_path,(char *) path));
#if defined(__amiga__)
if ((dirp->dd_fd) < 0) /* Directory doesn't exists */
goto error;
@@ -132,7 +132,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO),
ENTRIES_START_SIZE, ENTRIES_INCREMENT))
{
- my_free((gptr) buffer,MYF(0));
+ my_free((uchar*) buffer,MYF(0));
goto error;
}
init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE);
@@ -168,7 +168,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
else
finfo.mystat= NULL;
- if (push_dynamic(dir_entries_storage, (gptr)&finfo))
+ if (push_dynamic(dir_entries_storage, (uchar*)&finfo))
goto error;
}
@@ -208,13 +208,13 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
* Returns pointer to dst;
*/
-my_string directory_file_name (my_string dst, const char *src)
+char * directory_file_name (char * dst, const char *src)
{
#ifndef VMS
/* Process as Unix format: just remove test the final slash. */
- my_string end;
+ char * end;
if (src[0] == 0)
src= (char*) "."; /* Use empty as current */
@@ -230,7 +230,7 @@ my_string directory_file_name (my_string dst, const char *src)
long slen;
long rlen;
- my_string ptr, rptr;
+ char * ptr, rptr;
char bracket;
struct FAB fab = cc$rms_fab;
struct NAM nam = cc$rms_nam;
@@ -401,7 +401,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO),
ENTRIES_START_SIZE, ENTRIES_INCREMENT))
{
- my_free((gptr) buffer,MYF(0));
+ my_free((uchar*) buffer,MYF(0));
goto error;
}
init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE);
@@ -475,7 +475,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
else
finfo.mystat= NULL;
- if (push_dynamic(dir_entries_storage, (gptr)&finfo))
+ if (push_dynamic(dir_entries_storage, (uchar*)&finfo))
goto error;
}
#ifdef __BORLANDC__
@@ -533,13 +533,13 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
if ((m_used= (stat_area == NULL)))
if (!(stat_area = (MY_STAT *) my_malloc(sizeof(MY_STAT), my_flags)))
goto error;
- if (! stat((my_string) path, (struct stat *) stat_area) )
+ if (! stat((char *) path, (struct stat *) stat_area) )
DBUG_RETURN(stat_area);
DBUG_PRINT("error",("Got errno: %d from stat", errno));
my_errno= errno;
if (m_used) /* Free if new area */
- my_free((gptr) stat_area,MYF(0));
+ my_free((uchar*) stat_area,MYF(0));
error:
if (my_flags & (MY_FAE+MY_WME))
diff --git a/mysys/my_lockmem.c b/mysys/my_lockmem.c
index a58a5a340b1..b96331cd3cf 100644
--- a/mysys/my_lockmem.c
+++ b/mysys/my_lockmem.c
@@ -25,17 +25,17 @@
struct st_mem_list
{
LIST list;
- byte *page;
+ uchar *page;
uint size;
};
LIST *mem_list;
-byte *my_malloc_lock(uint size,myf MyFlags)
+uchar *my_malloc_lock(uint size,myf MyFlags)
{
int success;
uint pagesize=sysconf(_SC_PAGESIZE);
- byte *ptr;
+ uchar *ptr;
struct st_mem_list *element;
DBUG_ENTER("my_malloc_lock");
@@ -46,7 +46,7 @@ byte *my_malloc_lock(uint size,myf MyFlags)
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size);
DBUG_RETURN(0);
}
- success = mlock((byte*) ptr,size);
+ success = mlock((uchar*) ptr,size);
if (success != 0 && geteuid() == 0)
{
DBUG_PRINT("warning",("Failed to lock memory. errno %d\n",
@@ -59,11 +59,11 @@ byte *my_malloc_lock(uint size,myf MyFlags)
/* Add block in a list for munlock */
if (!(element=(struct st_mem_list*) my_malloc(sizeof(*element),MyFlags)))
{
- VOID(munlock((byte*) ptr,size));
+ VOID(munlock((uchar*) ptr,size));
free(ptr);
DBUG_RETURN(0);
}
- element->list.data=(byte*) element;
+ element->list.data=(uchar*) element;
element->page=ptr;
element->size=size;
pthread_mutex_lock(&THR_LOCK_malloc);
@@ -74,7 +74,7 @@ byte *my_malloc_lock(uint size,myf MyFlags)
}
-void my_free_lock(byte *ptr,myf Myflags __attribute__((unused)))
+void my_free_lock(uchar *ptr,myf Myflags __attribute__((unused)))
{
LIST *list;
struct st_mem_list *element=0;
@@ -85,14 +85,14 @@ void my_free_lock(byte *ptr,myf Myflags __attribute__((unused)))
element=(struct st_mem_list*) list->data;
if (ptr == element->page)
{ /* Found locked mem */
- VOID(munlock((byte*) ptr,element->size));
+ VOID(munlock((uchar*) ptr,element->size));
mem_list=list_delete(mem_list,list);
break;
}
}
pthread_mutex_unlock(&THR_LOCK_malloc);
if (element)
- my_free((gptr) element,MYF(0));
+ my_free((uchar*) element,MYF(0));
free(ptr); /* Free even if not locked */
}
diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c
index b0e775177a6..12793ad451b 100644
--- a/mysys/my_malloc.c
+++ b/mysys/my_malloc.c
@@ -23,11 +23,11 @@
/* My memory allocator */
-gptr my_malloc(unsigned int size, myf my_flags)
+void *my_malloc(size_t size, myf my_flags)
{
- gptr point;
+ void* point;
DBUG_ENTER("my_malloc");
- DBUG_PRINT("my",("size: %u my_flags: %d",size, my_flags));
+ DBUG_PRINT("my",("size: %lu my_flags: %d", (ulong) size, my_flags));
if (!size)
size=1; /* Safety */
@@ -44,14 +44,14 @@ gptr my_malloc(unsigned int size, myf my_flags)
else if (my_flags & MY_ZEROFILL)
bzero(point,size);
DBUG_PRINT("exit",("ptr: 0x%lx", (long) point));
- DBUG_RETURN(point);
+ DBUG_RETURN((void*) point);
} /* my_malloc */
/* Free memory allocated with my_malloc */
/*ARGSUSED*/
-void my_no_flags_free(gptr ptr)
+void my_no_flags_free(void* ptr)
{
DBUG_ENTER("my_free");
DBUG_PRINT("my",("ptr: 0x%lx", (long) ptr));
@@ -63,32 +63,32 @@ void my_no_flags_free(gptr ptr)
/* malloc and copy */
-gptr my_memdup(const byte *from, uint length, myf my_flags)
+void* my_memdup(const void *from, size_t length, myf my_flags)
{
- gptr ptr;
- if ((ptr=my_malloc(length,my_flags)) != 0)
- memcpy((byte*) ptr, (byte*) from,(size_t) length);
+ void *ptr;
+ if ((ptr= my_malloc(length,my_flags)) != 0)
+ memcpy(ptr, from, length);
return(ptr);
}
char *my_strdup(const char *from, myf my_flags)
{
- gptr ptr;
- uint length=(uint) strlen(from)+1;
- if ((ptr=my_malloc(length,my_flags)) != 0)
- memcpy((byte*) ptr, (byte*) from,(size_t) length);
- return((my_string) ptr);
+ char *ptr;
+ size_t length= strlen(from)+1;
+ if ((ptr= (char*) my_malloc(length, my_flags)))
+ memcpy((uchar*) ptr, (uchar*) from,(size_t) length);
+ return(ptr);
}
-char *my_strndup(const char *from, uint length, myf my_flags)
+char *my_strndup(const char *from, size_t length, myf my_flags)
{
- gptr ptr;
- if ((ptr=my_malloc(length+1,my_flags)) != 0)
+ char *ptr;
+ if ((ptr= (char*) my_malloc(length+1,my_flags)) != 0)
{
- memcpy((byte*) ptr, (byte*) from,(size_t) length);
- ((char*) ptr)[length]=0;
+ memcpy((uchar*) ptr, (uchar*) from, length);
+ ptr[length]=0;
}
return((char*) ptr);
}
diff --git a/mysys/my_memmem.c b/mysys/my_memmem.c
index 9230337409d..c000f14bc66 100644
--- a/mysys/my_memmem.c
+++ b/mysys/my_memmem.c
@@ -22,8 +22,9 @@
Returns a pointer to the beginning of the substring, needle, or NULL if the
substring is not found in haystack.
*/
+
void *my_memmem(const void *haystack, size_t haystacklen,
- const void *needle, size_t needlelen)
+ const void *needle, size_t needlelen)
{
const unsigned char *cursor;
const unsigned char *last_possible_needle_location =
diff --git a/mysys/my_once.c b/mysys/my_once.c
index fcb5af3ccbd..b6f6656fce2 100644
--- a/mysys/my_once.c
+++ b/mysys/my_once.c
@@ -36,10 +36,10 @@
No DBUG_ENTER... here to get smaller dbug-startup
*/
-gptr my_once_alloc(unsigned int Size, myf MyFlags)
+void* my_once_alloc(size_t Size, myf MyFlags)
{
- uint get_size,max_left;
- gptr point;
+ size_t get_size, max_left;
+ uchar* point;
reg1 USED_MEM *next;
reg2 USED_MEM **prev;
@@ -63,36 +63,36 @@ gptr my_once_alloc(unsigned int Size, myf MyFlags)
my_errno=errno;
if (MyFlags & (MY_FAE+MY_WME))
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),get_size);
- return((gptr) 0);
+ return((uchar*) 0);
}
- DBUG_PRINT("test",("my_once_malloc %u byte malloced",get_size));
+ DBUG_PRINT("test",("my_once_malloc %lu byte malloced", (ulong) get_size));
next->next= 0;
next->size= get_size;
next->left= get_size-ALIGN_SIZE(sizeof(USED_MEM));
*prev=next;
}
- point= (gptr) ((char*) next+ (next->size-next->left));
+ point= (uchar*) ((char*) next+ (next->size-next->left));
next->left-= Size;
if (MyFlags & MY_ZEROFILL)
bzero(point, Size);
- return(point);
+ return((void*) point);
} /* my_once_alloc */
char *my_once_strdup(const char *src,myf myflags)
{
- uint len= (uint) strlen(src)+1;
- char *dst=my_once_alloc(len, myflags);
+ size_t len= strlen(src)+1;
+ uchar *dst= my_once_alloc(len, myflags);
if (dst)
memcpy(dst, src, len);
- return dst;
+ return (char*) dst;
}
-char *my_once_memdup(const char *src, uint len, myf myflags)
+void *my_once_memdup(const void *src, size_t len, myf myflags)
{
- char *dst=my_once_alloc(len, myflags);
+ uchar *dst= my_once_alloc(len, myflags);
if (dst)
memcpy(dst, src, len);
return dst;
@@ -114,7 +114,7 @@ void my_once_free(void)
for (next=my_once_root_block ; next ; )
{
old=next; next= next->next ;
- free((gptr) old);
+ free((uchar*) old);
}
my_once_root_block=0;
diff --git a/mysys/my_open.c b/mysys/my_open.c
index 71e243c0173..5ad48e66b68 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -56,20 +56,20 @@ File my_open(const char *FileName, int Flags, myf MyFlags)
}
#ifndef __WIN__
if (Flags & O_SHARE)
- fd = sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO,
+ fd = sopen((char *) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO,
MY_S_IREAD | MY_S_IWRITE);
else
- fd = open((my_string) FileName, Flags | O_BINARY,
+ fd = open((char *) FileName, Flags | O_BINARY,
MY_S_IREAD | MY_S_IWRITE);
#else
- fd= my_sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO,
+ fd= my_sopen((char *) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO,
MY_S_IREAD | MY_S_IWRITE);
#endif
#elif !defined(NO_OPEN_3)
fd = open(FileName, Flags, my_umask); /* Normal unix */
#else
- fd = open((my_string) FileName, Flags);
+ fd = open((char *) FileName, Flags);
#endif
DBUG_RETURN(my_register_filename(fd, FileName, FILE_BY_OPEN,
EE_FILENOTFOUND, MyFlags));
diff --git a/mysys/my_pread.c b/mysys/my_pread.c
index f8f0fa49c10..070494e4f1d 100644
--- a/mysys/my_pread.c
+++ b/mysys/my_pread.c
@@ -20,61 +20,57 @@
#include <unistd.h>
#endif
- /* Read a chunk of bytes from a file */
-
-uint my_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset,
- myf MyFlags)
+/*
+ Read a chunk of bytes from a file from a given position
+
+ SYNOPSIOS
+ my_pread()
+ Filedes File decsriptor
+ Buffer Buffer to read data into
+ Count Number of bytes to read
+ offset Position to read from
+ MyFlags Flags
+
+ NOTES
+ This differs from the normal pread() call in that we don't care
+ to set the position in the file back to the original position
+ if the system doesn't support pread().
+
+ RETURN
+ (size_t) -1 Error
+ # Number of bytes read
+*/
+
+size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset,
+ myf MyFlags)
{
- uint readbytes;
+ size_t readbytes;
int error= 0;
DBUG_ENTER("my_pread");
DBUG_PRINT("my",("Fd: %d Seek: %lu Buffer: 0x%lx Count: %u MyFlags: %d",
- Filedes, (ulong) offset, (long) Buffer, Count, MyFlags));
-
+ Filedes, (ulong) offset, (long) Buffer, (uint) Count,
+ MyFlags));
for (;;)
{
#ifndef __WIN__
errno=0; /* Linux doesn't reset this */
#endif
#ifndef HAVE_PREAD
- os_off_t old_offset;
-
pthread_mutex_lock(&my_file_info[Filedes].mutex);
- /*
- As we cannot change the file pointer, we save the old position,
- before seeking to the given offset
- */
-
- error= (old_offset= lseek(Filedes, 0L, MY_SEEK_CUR)) == -1L ||
- lseek(Filedes, offset, MY_SEEK_SET) == -1L;
-
- if (!error) /* Seek was successful */
- {
- if ((readbytes = (uint) read(Filedes, Buffer, Count)) == -1L)
- my_errno= errno;
-
- /*
- We should seek back, even if read failed. If this fails,
- we will return an error. If read failed as well, we will
- save the errno from read, not from lseek().
- */
- if ((error= (lseek(Filedes, old_offset, MY_SEEK_SET) == -1L)) &&
- readbytes != -1L)
- my_errno= errno;
- }
-
+ readbytes= (uint) -1;
+ error= (lseek(Filedes, offset, MY_SEEK_SET) == (my_off_t) -1 ||
+ (readbytes= read(Filedes, Buffer, Count)) != Count);
pthread_mutex_unlock(&my_file_info[Filedes].mutex);
#else
- if ((error= ((readbytes =
- (uint) pread(Filedes, Buffer, Count, offset)) != Count)))
+ if ((error= ((readbytes= pread(Filedes, Buffer, Count, offset)) != Count)))
my_errno= errno;
#endif
if (error || readbytes != Count)
{
DBUG_PRINT("warning",("Read only %d bytes off %u from %d, errno: %d",
- (int) readbytes, Count,Filedes,my_errno));
+ (int) readbytes, (uint) Count,Filedes,my_errno));
#ifdef THREAD
- if ((readbytes == 0 || (int) readbytes == -1) && errno == EINTR)
+ if ((readbytes == 0 || readbytes == (size_t) -1) && errno == EINTR)
{
DBUG_PRINT("debug", ("my_pread() was interrupted and returned %d",
(int) readbytes));
@@ -83,14 +79,14 @@ uint my_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset,
#endif
if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
{
- if ((int) readbytes == -1)
+ if (readbytes == (size_t) -1)
my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG),
my_filename(Filedes),my_errno);
else if (MyFlags & (MY_NABP | MY_FNABP))
my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG),
my_filename(Filedes),my_errno);
}
- if ((int) readbytes == -1 || (MyFlags & (MY_FNABP | MY_NABP)))
+ if (readbytes == (size_t) -1 || (MyFlags & (MY_FNABP | MY_NABP)))
DBUG_RETURN(MY_FILE_ERROR); /* Return with error */
}
if (MyFlags & (MY_NABP | MY_FNABP))
@@ -100,65 +96,63 @@ uint my_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset,
} /* my_pread */
- /* Write a chunk of bytes to a file */
+/*
+ Write a chunk of bytes to a file at a given position
+
+ SYNOPSIOS
+ my_pwrite()
+ Filedes File decsriptor
+ Buffer Buffer to write data from
+ Count Number of bytes to write
+ offset Position to write to
+ MyFlags Flags
+
+ NOTES
+ This differs from the normal pwrite() call in that we don't care
+ to set the position in the file back to the original position
+ if the system doesn't support pwrite()
-uint my_pwrite(int Filedes, const byte *Buffer, uint Count, my_off_t offset,
- myf MyFlags)
+ RETURN
+ (size_t) -1 Error
+ # Number of bytes read
+ */
+
+size_t my_pwrite(int Filedes, const uchar *Buffer, size_t Count,
+ my_off_t offset, myf MyFlags)
{
- uint writenbytes,errors;
- ulong written;
+ size_t writenbytes, written;
+ uint errors;
DBUG_ENTER("my_pwrite");
- DBUG_PRINT("my",("Fd: %d Seek: %lu Buffer: 0x%lx Count: %d MyFlags: %d",
- Filedes, (ulong) offset, (long) Buffer, Count, MyFlags));
- errors=0; written=0L;
+ DBUG_PRINT("my",("Fd: %d Seek: %lu Buffer: 0x%lx Count: %u MyFlags: %d",
+ Filedes, (ulong) offset, (long) Buffer, (uint) Count,
+ MyFlags));
+ errors= 0;
+ written= 0;
for (;;)
{
#ifndef HAVE_PREAD
- int error= 0;
- os_off_t old_offset;
- writenbytes= (uint) -1;
+ int error;
+ writenbytes= (size_t) -1;
pthread_mutex_lock(&my_file_info[Filedes].mutex);
-
- /*
- As we cannot change the file pointer, we save the old position,
- before seeking to the given offset
- */
- error= ((old_offset= lseek(Filedes, 0L, MY_SEEK_CUR)) == -1L ||
- lseek(Filedes, offset, MY_SEEK_SET) == -1L);
-
- if (!error) /* Seek was successful */
- {
- if ((writenbytes = (uint) write(Filedes, Buffer, Count)) == -1L)
- my_errno= errno;
-
- /*
- We should seek back, even if write failed. If this fails,
- we will return an error. If write failed as well, we will
- save the errno from write, not from lseek().
- */
- if ((error= (lseek(Filedes, old_offset, MY_SEEK_SET) == -1L)) &&
- writenbytes != -1L)
- my_errno= errno;
- }
+ error= (lseek(Filedes, offset, MY_SEEK_SET) != (my_off_t) -1 &&
+ (writenbytes = write(Filedes, Buffer, Count)) == Count);
pthread_mutex_unlock(&my_file_info[Filedes].mutex);
-
- if (!error && writenbytes == Count)
+ if (error)
break;
#else
- if ((writenbytes = (uint) pwrite(Filedes, Buffer, Count,offset)) == Count)
+ if ((writenbytes= pwrite(Filedes, Buffer, Count,offset)) == Count)
break;
- else
- my_errno= errno;
+ my_errno= errno;
#endif
- if ((int) writenbytes != -1)
+ if (writenbytes != (size_t) -1)
{ /* Safegueard */
written+=writenbytes;
Buffer+=writenbytes;
Count-=writenbytes;
offset+=writenbytes;
}
- DBUG_PRINT("error",("Write only %d bytes",writenbytes));
+ DBUG_PRINT("error",("Write only %u bytes", (uint) writenbytes));
#ifndef NO_BACKGROUND
#ifdef THREAD
if (my_thread_var->abort)
@@ -173,8 +167,7 @@ uint my_pwrite(int Filedes, const byte *Buffer, uint Count, my_off_t offset,
VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC));
continue;
}
- if ((writenbytes > 0 && (uint) writenbytes != (uint) -1) ||
- my_errno == EINTR)
+ if ((writenbytes && writenbytes != (size_t) -1) || my_errno == EINTR)
continue; /* Retry */
#endif
if (MyFlags & (MY_NABP | MY_FNABP))
diff --git a/mysys/my_quick.c b/mysys/my_quick.c
index 15549dfb751..af8ef05bd5f 100644
--- a/mysys/my_quick.c
+++ b/mysys/my_quick.c
@@ -19,14 +19,14 @@
#include "my_nosys.h"
-uint my_quick_read(File Filedes,byte *Buffer,uint Count,myf MyFlags)
+size_t my_quick_read(File Filedes,uchar *Buffer,size_t Count,myf MyFlags)
{
- uint readbytes;
+ size_t readbytes;
- if ((readbytes = (uint) read(Filedes, Buffer, Count)) != Count)
+ if ((readbytes = read(Filedes, Buffer, Count)) != Count)
{
#ifndef DBUG_OFF
- if ((readbytes == 0 || (int) readbytes == -1) && errno == EINTR)
+ if ((readbytes == 0 || readbytes == (size_t) -1) && errno == EINTR)
{
DBUG_PRINT("error", ("my_quick_read() was interrupted and returned %d"
". This function does not retry the read!",
@@ -40,20 +40,20 @@ uint my_quick_read(File Filedes,byte *Buffer,uint Count,myf MyFlags)
}
-uint my_quick_write(File Filedes,const byte *Buffer,uint Count)
+size_t my_quick_write(File Filedes,const uchar *Buffer,size_t Count)
{
#ifndef DBUG_OFF
- uint writtenbytes;
+ size_t writtenbytes;
#endif
if ((
#ifndef DBUG_OFF
writtenbytes =
#endif
- (uint) write(Filedes,Buffer,Count)) != Count)
+ write(Filedes,Buffer,Count)) != Count)
{
#ifndef DBUG_OFF
- if ((writtenbytes == 0 || (int) writtenbytes == -1) && errno == EINTR)
+ if ((writtenbytes == 0 || writtenbytes == (size_t) -1) && errno == EINTR)
{
DBUG_PRINT("error", ("my_quick_write() was interrupted and returned %d"
". This function does not retry the write!",
@@ -61,7 +61,7 @@ uint my_quick_write(File Filedes,const byte *Buffer,uint Count)
}
#endif
my_errno=errno;
- return (uint) -1;
+ return (size_t) -1;
}
return 0;
}
diff --git a/mysys/my_read.c b/mysys/my_read.c
index a6c45340b0c..f3e8a4b300e 100644
--- a/mysys/my_read.c
+++ b/mysys/my_read.c
@@ -33,43 +33,44 @@
N number of bytes read.
*/
-uint my_read(File Filedes, byte *Buffer, uint Count, myf MyFlags)
+size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags)
{
- uint readbytes, save_count;
+ size_t readbytes, save_count;
DBUG_ENTER("my_read");
- DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %u MyFlags: %d",
- Filedes, (long) Buffer, Count, MyFlags));
+ DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %lu MyFlags: %d",
+ Filedes, (long) Buffer, (ulong) Count, MyFlags));
save_count= Count;
for (;;)
{
errno= 0; /* Linux doesn't reset this */
- if ((readbytes= (uint) read(Filedes, Buffer, Count)) != Count)
+ if ((readbytes= read(Filedes, Buffer, Count)) != Count)
{
my_errno= errno ? errno : -1;
- DBUG_PRINT("warning",("Read only %d bytes off %u from %d, errno: %d",
- (int) readbytes, Count, Filedes, my_errno));
+ DBUG_PRINT("warning",("Read only %d bytes off %lu from %d, errno: %d",
+ (int) readbytes, (ulong) Count, Filedes,
+ my_errno));
#ifdef THREAD
if ((readbytes == 0 || (int) readbytes == -1) && errno == EINTR)
{
- DBUG_PRINT("debug", ("my_read() was interrupted and returned %d",
- (int) readbytes));
+ DBUG_PRINT("debug", ("my_read() was interrupted and returned %ld",
+ (long) readbytes));
continue; /* Interrupted */
}
#endif
if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
{
- if ((int) readbytes == -1)
+ if (readbytes == (size_t) -1)
my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG),
my_filename(Filedes),my_errno);
else if (MyFlags & (MY_NABP | MY_FNABP))
my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG),
my_filename(Filedes),my_errno);
}
- if ((int) readbytes == -1 ||
+ if (readbytes == (size_t) -1 ||
((MyFlags & (MY_FNABP | MY_NABP)) && !(MyFlags & MY_FULL_IO)))
DBUG_RETURN(MY_FILE_ERROR); /* Return with error */
- if (readbytes > 0 && (MyFlags & MY_FULL_IO))
+ if (readbytes != (size_t) -1 && (MyFlags & MY_FULL_IO))
{
Buffer+= readbytes;
Count-= readbytes;
diff --git a/mysys/my_realloc.c b/mysys/my_realloc.c
index 43fbb0c1eee..c7cf1323cd4 100644
--- a/mysys/my_realloc.c
+++ b/mysys/my_realloc.c
@@ -22,12 +22,12 @@
/* My memory re allocator */
-gptr my_realloc(gptr oldpoint, uint size, myf my_flags)
+void* my_realloc(void* oldpoint, size_t size, myf my_flags)
{
- gptr point;
+ void *point;
DBUG_ENTER("my_realloc");
- DBUG_PRINT("my",("ptr: 0x%lx size: %u my_flags: %d", (long) oldpoint, size,
- my_flags));
+ DBUG_PRINT("my",("ptr: 0x%lx size: %lu my_flags: %d", (long) oldpoint,
+ (ulong) size, my_flags));
if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR))
DBUG_RETURN(my_malloc(size,my_flags));
@@ -48,7 +48,7 @@ gptr my_realloc(gptr oldpoint, uint size, myf my_flags)
free(oldpoint);
}
#else
- if ((point = (char*)realloc(oldpoint,size)) == NULL)
+ if ((point= (uchar*) realloc(oldpoint,size)) == NULL)
{
if (my_flags & MY_FREE_ON_ERROR)
my_free(oldpoint, my_flags);
diff --git a/mysys/my_static.c b/mysys/my_static.c
index 42dd9d71490..f884838f40a 100644
--- a/mysys/my_static.c
+++ b/mysys/my_static.c
@@ -27,7 +27,7 @@
my_bool timed_mutexes= 0;
/* from my_init */
-my_string home_dir=0;
+char * home_dir=0;
const char *my_progname=0;
char NEAR curr_dir[FN_REFLEN]= {0},
NEAR home_dir_buff[FN_REFLEN]= {0};
@@ -77,8 +77,8 @@ uint sf_malloc_prehunc=0, /* If you have problem with core- */
ulong sf_malloc_cur_memory= 0L; /* Current memory usage */
ulong sf_malloc_max_memory= 0L; /* Maximum memory usage */
uint sf_malloc_count= 0; /* Number of times NEW() was called */
-byte *sf_min_adress= (byte*) ~(unsigned long) 0L,
- *sf_max_adress= (byte*) 0L;
+uchar *sf_min_adress= (uchar*) ~(unsigned long) 0L,
+ *sf_max_adress= (uchar*) 0L;
/* Root of the linked list of struct st_irem */
struct st_irem *sf_malloc_root = NULL;
diff --git a/mysys/my_static.h b/mysys/my_static.h
index b438c936225..66e6ea1c280 100644
--- a/mysys/my_static.h
+++ b/mysys/my_static.h
@@ -60,7 +60,7 @@ extern const char *soundex_map;
extern USED_MEM* my_once_root_block;
extern uint my_once_extra;
-extern byte *sf_min_adress,*sf_max_adress;
+extern uchar *sf_min_adress,*sf_max_adress;
extern uint sf_malloc_count;
extern struct st_irem *sf_malloc_root;
diff --git a/mysys/my_vle.c b/mysys/my_vle.c
index 18339c877df..09f297eb553 100644
--- a/mysys/my_vle.c
+++ b/mysys/my_vle.c
@@ -39,16 +39,16 @@
bytes. On failure, the 'out' pointer is returned.
*/
-byte*
-my_vle_encode(byte* out, my_size_t max, ulong n)
+uchar*
+my_vle_encode(uchar* out, size_t max, ulong n)
{
- byte buf[my_vle_sizeof(n)];
- byte *ptr= buf;
- my_size_t len;
+ uchar buf[my_vle_sizeof(n)];
+ uchar *ptr= buf;
+ size_t len;
do
{
- *ptr++= (byte) (n & 0x7F);
+ *ptr++= (uchar) (n & 0x7F);
n>>= 7;
}
while (n > 0);
@@ -64,7 +64,7 @@ my_vle_encode(byte* out, my_size_t max, ulong n)
*/
while (ptr-- > buf)
{
- byte v= *ptr;
+ uchar v= *ptr;
if (ptr > buf)
v|= 0x80;
*out++= v;
@@ -89,11 +89,11 @@ my_vle_encode(byte* out, my_size_t max, ulong n)
more than sizeof(*result_ptr) + 1 bytes.
*/
-byte const*
-my_vle_decode(ulong *result_ptr, byte const *vle)
+uchar const*
+my_vle_decode(ulong *result_ptr, uchar const *vle)
{
ulong result= 0;
- my_size_t cnt= 1;
+ size_t cnt= 1;
do
{
diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c
index 353b2fced4e..d1b07b61408 100644
--- a/mysys/my_wincond.c
+++ b/mysys/my_wincond.c
@@ -201,7 +201,7 @@ int pthread_attr_setprio(pthread_attr_t *connect_att,int priority)
int pthread_attr_destroy(pthread_attr_t *connect_att)
{
- bzero((gptr) connect_att,sizeof(*connect_att));
+ bzero((uchar*) connect_att,sizeof(*connect_att));
return 0;
}
diff --git a/mysys/my_windac.c b/mysys/my_windac.c
index c711093b48f..f846853f7be 100644
--- a/mysys/my_windac.c
+++ b/mysys/my_windac.c
@@ -194,8 +194,8 @@ error:
FreeSid(everyone_sid);
if (htoken)
CloseHandle(htoken);
- my_free((gptr) sa, MYF(MY_ALLOW_ZERO_PTR));
- my_free((gptr) dacl, MYF(MY_ALLOW_ZERO_PTR));
+ my_free((uchar*) sa, MYF(MY_ALLOW_ZERO_PTR));
+ my_free((uchar*) dacl, MYF(MY_ALLOW_ZERO_PTR));
*psa= 0;
return 1;
}
@@ -215,8 +215,8 @@ void my_security_attr_free(SECURITY_ATTRIBUTES *sa)
My_security_attr *attr= (My_security_attr*)
(((char*)sa) + ALIGN_SIZE(sizeof(*sa)));
FreeSid(attr->everyone_sid);
- my_free((gptr) attr->dacl, MYF(0));
- my_free((gptr) sa, MYF(0));
+ my_free((uchar*) attr->dacl, MYF(0));
+ my_free((uchar*) sa, MYF(0));
}
}
diff --git a/mysys/my_write.c b/mysys/my_write.c
index 4c3d187e4e8..056a84f1794 100644
--- a/mysys/my_write.c
+++ b/mysys/my_write.c
@@ -20,28 +20,28 @@
/* Write a chunk of bytes to a file */
-uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags)
+size_t my_write(int Filedes, const uchar *Buffer, size_t Count, myf MyFlags)
{
- uint writenbytes,errors;
- ulong written;
+ size_t writenbytes, written;
+ uint errors;
DBUG_ENTER("my_write");
- DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %d MyFlags: %d",
- Filedes, (long) Buffer, Count, MyFlags));
- errors=0; written=0L;
+ DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %lu MyFlags: %d",
+ Filedes, (long) Buffer, (ulong) Count, MyFlags));
+ errors=0; written=0;
for (;;)
{
- if ((writenbytes = (uint) write(Filedes, Buffer, Count)) == Count)
+ if ((writenbytes= write(Filedes, Buffer, Count)) == Count)
break;
- if ((int) writenbytes != -1)
+ if (writenbytes != (size_t) -1)
{ /* Safeguard */
written+=writenbytes;
Buffer+=writenbytes;
Count-=writenbytes;
}
my_errno=errno;
- DBUG_PRINT("error",("Write only %d bytes, error: %d",
- writenbytes,my_errno));
+ DBUG_PRINT("error",("Write only %ld bytes, error: %d",
+ (long) writenbytes, my_errno));
#ifndef NO_BACKGROUND
#ifdef THREAD
if (my_thread_var->abort)
@@ -57,12 +57,12 @@ uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags)
continue;
}
- if ((writenbytes == 0 || (int) writenbytes == -1))
+ if ((writenbytes == 0 || writenbytes == (size_t) -1))
{
if (my_errno == EINTR)
{
- DBUG_PRINT("debug", ("my_write() was interrupted and returned %d",
- (int) writenbytes));
+ DBUG_PRINT("debug", ("my_write() was interrupted and returned %ld",
+ (long) writenbytes));
continue; /* Interrupted */
}
diff --git a/mysys/ptr_cmp.c b/mysys/ptr_cmp.c
index 4fdbad58aaf..24ab6a1ea9c 100644
--- a/mysys/ptr_cmp.c
+++ b/mysys/ptr_cmp.c
@@ -22,15 +22,15 @@
#include "mysys_priv.h"
#include <myisampack.h>
-static int ptr_compare(uint *compare_length, uchar **a, uchar **b);
-static int ptr_compare_0(uint *compare_length, uchar **a, uchar **b);
-static int ptr_compare_1(uint *compare_length, uchar **a, uchar **b);
-static int ptr_compare_2(uint *compare_length, uchar **a, uchar **b);
-static int ptr_compare_3(uint *compare_length, uchar **a, uchar **b);
+static int ptr_compare(size_t *compare_length, uchar **a, uchar **b);
+static int ptr_compare_0(size_t *compare_length, uchar **a, uchar **b);
+static int ptr_compare_1(size_t *compare_length, uchar **a, uchar **b);
+static int ptr_compare_2(size_t *compare_length, uchar **a, uchar **b);
+static int ptr_compare_3(size_t *compare_length, uchar **a, uchar **b);
/* Get a pointer to a optimal byte-compare function for a given size */
-qsort2_cmp get_ptr_compare (uint size)
+qsort2_cmp get_ptr_compare (size_t size)
{
if (size < 4)
return (qsort2_cmp) ptr_compare;
@@ -51,7 +51,7 @@ qsort2_cmp get_ptr_compare (uint size)
#define cmp(N) if (first[N] != last[N]) return (int) first[N] - (int) last[N]
-static int ptr_compare(uint *compare_length, uchar **a, uchar **b)
+static int ptr_compare(size_t *compare_length, uchar **a, uchar **b)
{
reg3 int length= *compare_length;
reg1 uchar *first,*last;
@@ -66,7 +66,7 @@ static int ptr_compare(uint *compare_length, uchar **a, uchar **b)
}
-static int ptr_compare_0(uint *compare_length,uchar **a, uchar **b)
+static int ptr_compare_0(size_t *compare_length,uchar **a, uchar **b)
{
reg3 int length= *compare_length;
reg1 uchar *first,*last;
@@ -87,7 +87,7 @@ static int ptr_compare_0(uint *compare_length,uchar **a, uchar **b)
}
-static int ptr_compare_1(uint *compare_length,uchar **a, uchar **b)
+static int ptr_compare_1(size_t *compare_length,uchar **a, uchar **b)
{
reg3 int length= *compare_length-1;
reg1 uchar *first,*last;
@@ -108,7 +108,7 @@ static int ptr_compare_1(uint *compare_length,uchar **a, uchar **b)
return (0);
}
-static int ptr_compare_2(uint *compare_length,uchar **a, uchar **b)
+static int ptr_compare_2(size_t *compare_length,uchar **a, uchar **b)
{
reg3 int length= *compare_length-2;
reg1 uchar *first,*last;
@@ -130,7 +130,7 @@ static int ptr_compare_2(uint *compare_length,uchar **a, uchar **b)
return (0);
}
-static int ptr_compare_3(uint *compare_length,uchar **a, uchar **b)
+static int ptr_compare_3(size_t *compare_length,uchar **a, uchar **b)
{
reg3 int length= *compare_length-3;
reg1 uchar *first,*last;
@@ -153,7 +153,7 @@ static int ptr_compare_3(uint *compare_length,uchar **a, uchar **b)
return (0);
}
-void my_store_ptr(byte *buff, uint pack_length, my_off_t pos)
+void my_store_ptr(uchar *buff, size_t pack_length, my_off_t pos)
{
switch (pack_length) {
#if SIZEOF_OFF_T > 4
@@ -171,7 +171,7 @@ void my_store_ptr(byte *buff, uint pack_length, my_off_t pos)
return;
}
-my_off_t my_get_ptr(byte *ptr, uint pack_length)
+my_off_t my_get_ptr(uchar *ptr, size_t pack_length)
{
my_off_t pos;
switch (pack_length) {
diff --git a/mysys/queues.c b/mysys/queues.c
index 5970922284f..d8a7ca19bee 100644
--- a/mysys/queues.c
+++ b/mysys/queues.c
@@ -49,11 +49,11 @@
*/
int init_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
- pbool max_at_top, int (*compare) (void *, byte *, byte *),
+ pbool max_at_top, int (*compare) (void *, uchar *, uchar *),
void *first_cmp_arg)
{
DBUG_ENTER("init_queue");
- if ((queue->root= (byte **) my_malloc((max_elements+1)*sizeof(void*),
+ if ((queue->root= (uchar **) my_malloc((max_elements+1)*sizeof(void*),
MYF(MY_WME))) == 0)
DBUG_RETURN(1);
queue->elements=0;
@@ -92,7 +92,7 @@ int init_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
*/
int init_queue_ex(QUEUE *queue, uint max_elements, uint offset_to_key,
- pbool max_at_top, int (*compare) (void *, byte *, byte *),
+ pbool max_at_top, int (*compare) (void *, uchar *, uchar *),
void *first_cmp_arg, uint auto_extent)
{
int ret;
@@ -129,7 +129,7 @@ int init_queue_ex(QUEUE *queue, uint max_elements, uint offset_to_key,
*/
int reinit_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
- pbool max_at_top, int (*compare) (void *, byte *, byte *),
+ pbool max_at_top, int (*compare) (void *, uchar *, uchar *),
void *first_cmp_arg)
{
DBUG_ENTER("reinit_queue");
@@ -162,11 +162,11 @@ int reinit_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
int resize_queue(QUEUE *queue, uint max_elements)
{
- byte **new_root;
+ uchar **new_root;
DBUG_ENTER("resize_queue");
if (queue->max_elements == max_elements)
DBUG_RETURN(0);
- if ((new_root= (byte **) my_realloc((void *)queue->root,
+ if ((new_root= (uchar **) my_realloc((void *)queue->root,
(max_elements+1)*sizeof(void*),
MYF(MY_WME))) == 0)
DBUG_RETURN(1);
@@ -196,7 +196,7 @@ void delete_queue(QUEUE *queue)
DBUG_ENTER("delete_queue");
if (queue->root)
{
- my_free((gptr) queue->root,MYF(0));
+ my_free((uchar*) queue->root,MYF(0));
queue->root=0;
}
DBUG_VOID_RETURN;
@@ -205,7 +205,7 @@ void delete_queue(QUEUE *queue)
/* Code for insert, search and delete of elements */
-void queue_insert(register QUEUE *queue, byte *element)
+void queue_insert(register QUEUE *queue, uchar *element)
{
reg2 uint idx, next;
int cmp;
@@ -234,7 +234,7 @@ void queue_insert(register QUEUE *queue, byte *element)
*/
-int queue_insert_safe(register QUEUE *queue, byte *element)
+int queue_insert_safe(register QUEUE *queue, uchar *element)
{
if (queue->elements == queue->max_elements)
@@ -253,9 +253,9 @@ int queue_insert_safe(register QUEUE *queue, byte *element)
/* Remove item from queue */
/* Returns pointer to removed element */
-byte *queue_remove(register QUEUE *queue, uint idx)
+uchar *queue_remove(register QUEUE *queue, uint idx)
{
- byte *element;
+ uchar *element;
DBUG_ASSERT(idx < queue->max_elements);
element= queue->root[++idx]; /* Intern index starts from 1 */
queue->root[idx]= queue->root[queue->elements--];
@@ -276,7 +276,7 @@ void queue_replaced(QUEUE *queue)
void _downheap(register QUEUE *queue, uint idx)
{
- byte *element;
+ uchar *element;
uint elements,half_queue,offset_to_key, next_index;
bool first= TRUE;
uint start_idx= idx;
@@ -332,7 +332,7 @@ void _downheap(register QUEUE *queue, uint idx)
/* Fix heap when index have changed */
void _downheap(register QUEUE *queue, uint idx)
{
- byte *element;
+ uchar *element;
uint elements,half_queue,next_index,offset_to_key;
int cmp;
@@ -483,7 +483,7 @@ void calculate_end_next(uint part)
}
return;
}
-static int test_compare(void *null_arg, byte *a, byte *b)
+static int test_compare(void *null_arg, uchar *a, uchar *b)
{
uint a_num= (*(uint*)a) & 0x3FFFFF;
uint b_num= (*(uint*)b) & 0x3FFFFF;
@@ -541,9 +541,9 @@ void perform_insert(QUEUE *queue)
}
num_array[i]= num + (i << 22);
if (fix_used)
- queue_element(queue, i-1)= (byte*)&num_array[i];
+ queue_element(queue, i-1)= (uchar*)&num_array[i];
else
- queue_insert(queue, (byte*)&num_array[i]);
+ queue_insert(queue, (uchar*)&num_array[i]);
} while (++i <= no_parts);
if (fix_used)
{
@@ -573,7 +573,7 @@ bool perform_ins_del(QUEUE *queue, bool max_ind)
num_array[part]-= part;
else
num_array[part]+= part;
- queue_top(queue)= (byte*)&num_array[part];
+ queue_top(queue)= (uchar*)&num_array[part];
queue_replaced(queue);
}
} while (++i < no_loops);
@@ -665,7 +665,7 @@ static void benchmark_test()
num+= 16;
part= num >> 22;
num_array[part]= num;
- queue_top(queue)= (byte*)&num_array[part];
+ queue_top(queue)= (uchar*)&num_array[part];
queue_replaced(queue);
}
for (i= 0; i < 16; i++)
diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c
index f2a4c280610..30c501c54ee 100644
--- a/mysys/safemalloc.c
+++ b/mysys/safemalloc.c
@@ -82,7 +82,7 @@ static int sf_malloc_tampered= 0;
/* Static functions prototypes */
-static int check_ptr(const char *where, byte *ptr, const char *sFile,
+static int check_ptr(const char *where, uchar *ptr, const char *sFile,
uint uLine);
static int _checkchunk(struct st_irem *pRec, const char *sFile, uint uLine);
@@ -119,12 +119,12 @@ static int _checkchunk(struct st_irem *pRec, const char *sFile, uint uLine);
/* Allocate some memory. */
-gptr _mymalloc(uint size, const char *filename, uint lineno, myf MyFlags)
+void *_mymalloc(size_t size, const char *filename, uint lineno, myf MyFlags)
{
struct st_irem *irem;
- char *data;
+ uchar *data;
DBUG_ENTER("_mymalloc");
- DBUG_PRINT("enter",("Size: %u",size));
+ DBUG_PRINT("enter",("Size: %lu", (ulong) size));
if (!sf_malloc_quick)
(void) _sanity (filename, lineno);
@@ -151,8 +151,8 @@ gptr _mymalloc(uint size, const char *filename, uint lineno, myf MyFlags)
my_errno=errno;
sprintf(buff,"Out of memory at line %d, '%s'", lineno, filename);
my_message(EE_OUTOFMEMORY, buff, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH));
- sprintf(buff,"needed %d byte (%ldk), memory in use: %ld bytes (%ldk)",
- size, (size + 1023L) / 1024L,
+ sprintf(buff,"needed %u byte (%ldk), memory in use: %ld bytes (%ldk)",
+ (uint) size, (uint) (size + 1023L) / 1024L,
sf_malloc_max_memory, (sf_malloc_max_memory + 1023L) / 1024L);
my_message(EE_OUTOFMEMORY, buff, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH));
}
@@ -160,18 +160,18 @@ gptr _mymalloc(uint size, const char *filename, uint lineno, myf MyFlags)
sf_malloc_max_memory,lineno, filename));
if (MyFlags & MY_FAE)
exit(1);
- DBUG_RETURN ((gptr) 0);
+ DBUG_RETURN ((void*) 0);
}
/* Fill up the structure */
- data= (((char*) irem) + ALIGN_SIZE(sizeof(struct st_irem)) +
+ data= (((uchar*) irem) + ALIGN_SIZE(sizeof(struct st_irem)) +
sf_malloc_prehunc);
*((uint32*) (data-sizeof(uint32)))= MAGICKEY;
data[size + 0]= MAGICEND0;
data[size + 1]= MAGICEND1;
data[size + 2]= MAGICEND2;
data[size + 3]= MAGICEND3;
- irem->filename= (my_string) filename;
+ irem->filename= (char *) filename;
irem->linenum= lineno;
irem->datasize= size;
irem->prev= NULL;
@@ -198,7 +198,7 @@ gptr _mymalloc(uint size, const char *filename, uint lineno, myf MyFlags)
sf_min_adress= data;
if (sf_max_adress < data)
sf_max_adress= data;
- DBUG_RETURN ((gptr) data);
+ DBUG_RETURN((void*) data);
}
@@ -207,8 +207,8 @@ gptr _mymalloc(uint size, const char *filename, uint lineno, myf MyFlags)
Free then old memoryblock
*/
-gptr _myrealloc(register gptr ptr, register uint size,
- const char *filename, uint lineno, myf MyFlags)
+void *_myrealloc(register void *ptr, register size_t size,
+ const char *filename, uint lineno, myf MyFlags)
{
struct st_irem *irem;
char *data;
@@ -220,8 +220,8 @@ gptr _myrealloc(register gptr ptr, register uint size,
if (!sf_malloc_quick)
(void) _sanity (filename, lineno);
- if (check_ptr("Reallocating", (byte*) ptr, filename, lineno))
- DBUG_RETURN((gptr) NULL);
+ if (check_ptr("Reallocating", (uchar*) ptr, filename, lineno))
+ DBUG_RETURN((uchar*) NULL);
irem= (struct st_irem *) (((char*) ptr) - ALIGN_SIZE(sizeof(struct st_irem))-
sf_malloc_prehunc);
@@ -232,13 +232,13 @@ gptr _myrealloc(register gptr ptr, register uint size,
DBUG_PRINT("safe",("Reallocating unallocated data at line %d, '%s'",
lineno, filename));
(void) fflush(stderr);
- DBUG_RETURN((gptr) NULL);
+ DBUG_RETURN((uchar*) NULL);
}
if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */
{
size=min(size, irem->datasize); /* Move as much as possibly */
- memcpy((byte*) data, ptr, (size_t) size); /* Copy old data */
+ memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */
_myfree(ptr, filename, lineno, 0); /* Free not needed area */
}
else
@@ -254,7 +254,7 @@ gptr _myrealloc(register gptr ptr, register uint size,
/* Deallocate some memory. */
-void _myfree(gptr ptr, const char *filename, uint lineno, myf myflags)
+void _myfree(void *ptr, const char *filename, uint lineno, myf myflags)
{
struct st_irem *irem;
DBUG_ENTER("_myfree");
@@ -264,7 +264,7 @@ void _myfree(gptr ptr, const char *filename, uint lineno, myf myflags)
(void) _sanity (filename, lineno);
if ((!ptr && (myflags & MY_ALLOW_ZERO_PTR)) ||
- check_ptr("Freeing",(byte*) ptr,filename,lineno))
+ check_ptr("Freeing",(uchar*) ptr,filename,lineno))
DBUG_VOID_RETURN;
/* Calculate the address of the remember structure */
@@ -316,7 +316,7 @@ void _myfree(gptr ptr, const char *filename, uint lineno, myf myflags)
/* Check if we have a wrong pointer */
-static int check_ptr(const char *where, byte *ptr, const char *filename,
+static int check_ptr(const char *where, uchar *ptr, const char *filename,
uint lineno)
{
if (!ptr)
@@ -503,12 +503,12 @@ int _sanity(const char *filename, uint lineno)
/* malloc and copy */
-gptr _my_memdup(const byte *from, uint length, const char *filename,
- uint lineno, myf MyFlags)
+void *_my_memdup(const void *from, size_t length, const char *filename,
+ uint lineno, myf MyFlags)
{
- gptr ptr;
- if ((ptr=_mymalloc(length,filename,lineno,MyFlags)) != 0)
- memcpy((byte*) ptr, (byte*) from,(size_t) length);
+ void *ptr;
+ if ((ptr= _mymalloc(length,filename,lineno,MyFlags)) != 0)
+ memcpy(ptr, from, length);
return(ptr);
} /*_my_memdup */
@@ -516,23 +516,23 @@ gptr _my_memdup(const byte *from, uint length, const char *filename,
char *_my_strdup(const char *from, const char *filename, uint lineno,
myf MyFlags)
{
- gptr ptr;
- uint length=(uint) strlen(from)+1;
- if ((ptr=_mymalloc(length,filename,lineno,MyFlags)) != 0)
- memcpy((byte*) ptr, (byte*) from,(size_t) length);
- return((char*) ptr);
+ char *ptr;
+ size_t length= strlen(from)+1;
+ if ((ptr= (char*) _mymalloc(length,filename,lineno,MyFlags)) != 0)
+ memcpy((uchar*) ptr, (uchar*) from, (size_t) length);
+ return(ptr);
} /* _my_strdup */
-char *_my_strndup(const char *from, uint length,
- const char *filename, uint lineno,
- myf MyFlags)
+char *_my_strndup(const char *from, size_t length,
+ const char *filename, uint lineno,
+ myf MyFlags)
{
- gptr ptr;
- if ((ptr=_mymalloc(length+1,filename,lineno,MyFlags)) != 0)
+ char *ptr;
+ if ((ptr= (char*) _mymalloc(length+1,filename,lineno,MyFlags)) != 0)
{
- memcpy((byte*) ptr, (byte*) from,(size_t) length);
+ memcpy((uchar*) ptr, (uchar*) from, (size_t) length);
ptr[length]=0;
}
- return((char *) ptr);
+ return(ptr);
}
diff --git a/mysys/string.c b/mysys/string.c
index e1ff9ec8c26..b234a589406 100644
--- a/mysys/string.c
+++ b/mysys/string.c
@@ -23,7 +23,7 @@
#include <m_string.h>
my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
- uint init_alloc, uint alloc_increment)
+ size_t init_alloc, size_t alloc_increment)
{
uint length;
DBUG_ENTER("init_dynamic_string");
@@ -31,7 +31,7 @@ my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
if (!alloc_increment)
alloc_increment=128;
length=1;
- if (init_str && (length= (uint) strlen(init_str)+1) < init_alloc)
+ if (init_str && (length= strlen(init_str)+1) < init_alloc)
init_alloc=((length+alloc_increment-1)/alloc_increment)*alloc_increment;
if (!init_alloc)
init_alloc=alloc_increment;
@@ -72,7 +72,7 @@ my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str)
}
-my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size)
+my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size)
{
DBUG_ENTER("dynstr_realloc");
@@ -95,7 +95,7 @@ my_bool dynstr_append(DYNAMIC_STRING *str, const char *append)
my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
- uint length)
+ size_t length)
{
char *new_ptr;
if (str->length+length >= str->max_length)
@@ -114,26 +114,30 @@ my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
return FALSE;
}
-my_bool dynstr_trunc(DYNAMIC_STRING *str, int n)
+
+my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n)
{
str->length-=n;
str->str[str->length]= '\0';
return FALSE;
}
-/** Concatenates any number of strings, escapes any OS quote in the result then
- * surround the whole affair in another set of quotes which is finally appended
- * to specified DYNAMIC_STRING. This function is especially useful when
- * building strings to be executed with the system() function.
- * @param str Dynamic String which will have addtional strings appended.
- * @param append String to be appended.
- * @param ... Optional. Additional string(s) to be appended.
- *
- * @note The final argument in the list must be NullS even if no additional
- * options are passed.
- *
- * @return True = Success.
- */
+/*
+ Concatenates any number of strings, escapes any OS quote in the result then
+ surround the whole affair in another set of quotes which is finally appended
+ to specified DYNAMIC_STRING. This function is especially useful when
+ building strings to be executed with the system() function.
+
+ @param str Dynamic String which will have addtional strings appended.
+ @param append String to be appended.
+ @param ... Optional. Additional string(s) to be appended.
+
+ @note The final argument in the list must be NullS even if no additional
+ options are passed.
+
+ @return True = Success.
+*/
+
my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...)
{
#ifdef __WIN__
diff --git a/mysys/testhash.c b/mysys/testhash.c
index 0961558afd3..2add2ebd2d7 100644
--- a/mysys/testhash.c
+++ b/mysys/testhash.c
@@ -38,11 +38,11 @@ my_bool hash_check(HASH *hash);
void free_record(void *record);
-static byte *hash2_key(const byte *rec,uint *length,
+static uchar *hash2_key(const uchar *rec,uint *length,
my_bool not_used __attribute__((unused)))
{
*length=(uint) (uchar) rec[reclength-1];
- return (byte*) rec;
+ return (uchar*) rec;
}
/* main program */
@@ -196,7 +196,7 @@ static int do_test()
pos=0;
while ((recpos=hash_element(&hash,0)))
{
- record=(byte*) my_malloc(reclength,MYF(MY_FAE));
+ record=(uchar*) my_malloc(reclength,MYF(MY_FAE));
memcpy(record,recpos,reclength);
record[reclength-1]=rnd(5)+1;
if (my_hash_insert(&hash2,record))
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index 471ec0ab10d..81093be3678 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -60,7 +60,7 @@ static void *alarm_handler(void *arg);
static sig_handler thread_alarm(int sig __attribute__((unused)));
static int compare_ulong(void *not_used __attribute__((unused)),
- byte *a_ptr,byte* b_ptr)
+ uchar *a_ptr,uchar* b_ptr)
{
ulong a=*((ulong*) a_ptr),b= *((ulong*) b_ptr);
return (a < b) ? -1 : (a == b) ? 0 : 1;
@@ -205,7 +205,7 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data)
alarm_data->alarmed=0;
alarm_data->thread= current_my_thread_var->pthread_self;
alarm_data->thread_id= current_my_thread_var->id;
- queue_insert(&alarm_queue,(byte*) alarm_data);
+ queue_insert(&alarm_queue,(uchar*) alarm_data);
/* Reschedule alarm if the current one has more than sec left */
if (reschedule)
@@ -237,14 +237,14 @@ void thr_end_alarm(thr_alarm_t *alarmed)
pthread_sigmask(SIG_BLOCK,&full_signal_set,&old_mask);
pthread_mutex_lock(&LOCK_alarm);
- alarm_data= (ALARM*) ((byte*) *alarmed - offsetof(ALARM,alarmed));
+ alarm_data= (ALARM*) ((uchar*) *alarmed - offsetof(ALARM,alarmed));
for (i=0 ; i < alarm_queue.elements ; i++)
{
if ((ALARM*) queue_element(&alarm_queue,i) == alarm_data)
{
queue_remove(&alarm_queue,i),MYF(0);
if (alarm_data->malloced)
- my_free((gptr) alarm_data,MYF(0));
+ my_free((uchar*) alarm_data,MYF(0));
found++;
#ifdef DBUG_OFF
break;
@@ -464,7 +464,7 @@ void thr_alarm_kill(my_thread_id thread_id)
{
ALARM *tmp=(ALARM*) queue_remove(&alarm_queue,i);
tmp->expire_time=0;
- queue_insert(&alarm_queue,(byte*) tmp);
+ queue_insert(&alarm_queue,(uchar*) tmp);
reschedule_alarms();
break;
}
@@ -755,7 +755,7 @@ static void *test_thread(void *arg)
thread_count--;
VOID(pthread_cond_signal(&COND_thread_count)); /* Tell main we are ready */
pthread_mutex_unlock(&LOCK_thread_count);
- free((gptr) arg);
+ free((uchar*) arg);
return 0;
}
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index 94c34eef2fa..20edffb49c2 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -899,7 +899,7 @@ end:
*/
-#define LOCK_CMP(A,B) ((byte*) (A->lock) - (uint) ((A)->type) < (byte*) (B->lock)- (uint) ((B)->type))
+#define LOCK_CMP(A,B) ((uchar*) (A->lock) - (uint) ((A)->type) < (uchar*) (B->lock)- (uint) ((B)->type))
static void sort_locks(THR_LOCK_DATA **data,uint count)
{
@@ -1600,7 +1600,7 @@ static void *test_thread(void *arg)
thread_count--;
VOID(pthread_cond_signal(&COND_thread_count)); /* Tell main we are ready */
pthread_mutex_unlock(&LOCK_thread_count);
- free((gptr) arg);
+ free((uchar*) arg);
return 0;
}
diff --git a/mysys/tree.c b/mysys/tree.c
index 2e6868e0777..ef33f75b7c6 100644
--- a/mysys/tree.c
+++ b/mysys/tree.c
@@ -93,7 +93,7 @@ void init_tree(TREE *tree, ulong default_alloc_size, ulong memory_limit,
if (default_alloc_size < DEFAULT_ALLOC_SIZE)
default_alloc_size= DEFAULT_ALLOC_SIZE;
default_alloc_size= MY_ALIGN(default_alloc_size, DEFAULT_ALIGN_SIZE);
- bzero((gptr) &tree->null_element,sizeof(tree->null_element));
+ bzero((uchar*) &tree->null_element,sizeof(tree->null_element));
tree->root= &tree->null_element;
tree->compare=compare;
tree->size_of_element=size > 0 ? (uint) size : 0;
@@ -247,12 +247,12 @@ TREE_ELEMENT *tree_insert(TREE *tree, void *key, uint key_size,
else
{
*((void**) (element+1))= (void*) ((void **) (element+1)+1);
- memcpy((byte*) *((void **) (element+1)),key,
+ memcpy((uchar*) *((void **) (element+1)),key,
(size_t) (key_size-sizeof(void*)));
}
}
else
- memcpy((byte*) element+tree->offset_to_key,key,(size_t) key_size);
+ memcpy((uchar*) element+tree->offset_to_key,key,(size_t) key_size);
element->count=1; /* May give warning in purify */
tree->elements_in_tree++;
rb_insert(tree,parent,element); /* rebalance tree */
@@ -326,7 +326,7 @@ int tree_delete(TREE *tree, void *key, uint key_size, void *custom_arg)
if (tree->free)
(*tree->free)(ELEMENT_KEY(tree,element), free_free, tree->custom_arg);
tree->allocated-= sizeof(TREE_ELEMENT) + tree->size_of_element + key_size;
- my_free((gptr) element,MYF(0));
+ my_free((uchar*) element,MYF(0));
tree->elements_in_tree--;
return 0;
}
diff --git a/mysys/trie.c b/mysys/trie.c
index 8daa6f3e661..5738b9b866b 100644
--- a/mysys/trie.c
+++ b/mysys/trie.c
@@ -101,7 +101,7 @@ void trie_free (TRIE *trie)
/*
SYNOPSIS
- my_bool trie_insert (TRIE *trie, const byte *key, uint keylen);
+ my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen);
trie - valid pointer to `TRIE'
key - valid pointer to key to insert
keylen - non-0 key length
@@ -118,11 +118,11 @@ void trie_free (TRIE *trie)
However it can be freed with trie_free().
*/
-my_bool trie_insert (TRIE *trie, const byte *key, uint keylen)
+my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen)
{
TRIE_NODE *node;
TRIE_NODE *next;
- byte p;
+ uchar p;
uint k;
DBUG_ENTER("trie_insert");
DBUG_ASSERT(trie && key && keylen);
@@ -211,7 +211,7 @@ my_bool ac_trie_prepare (TRIE *trie)
fail= fail->fail;
}
}
- my_free((gptr)tmp_nodes, MYF(0));
+ my_free((uchar*)tmp_nodes, MYF(0));
DBUG_RETURN(FALSE);
}
diff --git a/mysys/typelib.c b/mysys/typelib.c
index a3b669d2e54..2590ca6a03f 100644
--- a/mysys/typelib.c
+++ b/mysys/typelib.c
@@ -25,7 +25,7 @@ int find_type_or_exit(const char *x, TYPELIB *typelib, const char *option)
int res;
const char **ptr;
- if ((res= find_type((my_string) x, typelib, 2)) <= 0)
+ if ((res= find_type((char *) x, typelib, 2)) <= 0)
{
ptr= typelib->type_names;
if (!*x)
@@ -64,10 +64,11 @@ int find_type_or_exit(const char *x, TYPELIB *typelib, const char *option)
>0 Offset+1 in typelib for matched string
*/
+
int find_type(char *x, const TYPELIB *typelib, uint full_name)
{
int find,pos,findpos;
- reg1 my_string i;
+ reg1 char * i;
reg2 const char *j;
DBUG_ENTER("find_type");
DBUG_PRINT("enter",("x: '%s' lib: 0x%lx", x, (long) typelib));
@@ -119,7 +120,7 @@ int find_type(char *x, const TYPELIB *typelib, uint full_name)
/* Get name of type nr 'nr' */
/* Warning first type is 1, 0 = empty field */
-void make_type(register my_string to, register uint nr,
+void make_type(register char * to, register uint nr,
register TYPELIB *typelib)
{
DBUG_ENTER("make_type");