diff options
Diffstat (limited to 'mysys')
68 files changed, 324 insertions, 1635 deletions
diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 0ea65ce8e4b..83615c82e2a 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -29,10 +29,10 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_ my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_handler.c my_init.c my_lib.c my_lock.c my_lockmem.c my_malloc.c my_mess.c my_mkdir.c my_mmap.c my_net.c my_once.c my_open.c my_pread.c my_pthread.c - my_quick.c my_read.c my_realloc.c my_redel.c my_rename.c my_seek.c my_sleep.c + my_quick.c my_read.c my_redel.c my_rename.c my_seek.c my_sleep.c my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c my_write.c ptr_cmp.c queues.c stacktrace.c - rijndael.c safemalloc.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c + rijndael.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c lf_alloc-pin.c lf_dynarray.c lf_hash.c my_atomic.c my_getncpus.c diff --git a/mysys/Makefile.am b/mysys/Makefile.am index d5bffd874b2..a9e3f16c548 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -29,9 +29,8 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \ mf_keycaches.c my_crc32.c \ mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \ mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \ - my_malloc.c my_realloc.c my_once.c mulalloc.c \ - my_alloc.c safemalloc.c my_new.cc \ - my_vle.c my_atomic.c lf_hash.c \ + my_malloc.c my_once.c mulalloc.c \ + my_alloc.c my_new.cc my_vle.c my_atomic.c lf_hash.c \ lf_dynarray.c lf_alloc-pin.c \ my_fopen.c my_fstream.c my_getsystime.c \ my_error.c errors.c my_div.c my_mess.c \ @@ -52,7 +51,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \ my_net.c my_port.c my_sleep.c \ charset.c charset-def.c my_bitmap.c my_bit.c md5.c \ my_gethostbyname.c rijndael.c my_aes.c sha1.c \ - my_handler.c my_netware.c my_largepage.c \ + my_handler.c my_largepage.c \ my_memmem.c stacktrace.c \ my_windac.c my_access.c base64.c my_libwrap.c \ my_rdtsc.c diff --git a/mysys/array.c b/mysys/array.c index a1c49c2589d..70c7a59aa3a 100644 --- a/mysys/array.c +++ b/mysys/array.c @@ -42,7 +42,7 @@ my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size, void *init_buffer, uint init_alloc, - uint alloc_increment CALLER_INFO_PROTO) + uint alloc_increment) { DBUG_ENTER("init_dynamic_array"); if (!alloc_increment) @@ -67,14 +67,13 @@ my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size, Since the dynamic array is usable even if allocation fails here malloc should not throw an error */ - if (!(array->buffer= (uchar*) my_malloc_ci(element_size*init_alloc, MYF(0)))) + if (!(array->buffer= (uchar*) my_malloc(element_size*init_alloc, MYF(0)))) array->max_element=0; DBUG_RETURN(FALSE); } my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size, - uint init_alloc, - uint alloc_increment CALLER_INFO_PROTO) + uint init_alloc, uint alloc_increment) { /* placeholder to preserve ABI */ return my_init_dynamic_array_ci(array, element_size, init_alloc, @@ -306,7 +305,7 @@ void delete_dynamic(DYNAMIC_ARRAY *array) else if (array->buffer) { - my_free(array->buffer,MYF(MY_WME)); + my_free(array->buffer); array->buffer=0; array->elements=array->max_element=0; } diff --git a/mysys/charset.c b/mysys/charset.c index 9f9d18e31a4..167d6b8ff6e 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -383,11 +383,11 @@ static my_bool my_read_charset_file(const char *filename, myf myflags) #endif } - my_free(buf, myflags); + my_free(buf); return FALSE; error: - my_free(buf, myflags); + my_free(buf); return TRUE; } diff --git a/mysys/default.c b/mysys/default.c index fc119bb3283..8002a1a0307 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -118,7 +118,6 @@ static int search_default_file_with_ext(Process_option_func func, - Windows: GetWindowsDirectory() - Windows: C:/ - Windows: Directory above where the executable is located - - Netware: sys:/etc/ - Unix: /etc/ - Unix: /etc/mysql/ - Unix: --sysconfdir=<path> (compile-time option) @@ -708,7 +707,7 @@ static int search_default_file_with_ext(Process_option_func opt_handler, strmov(name,config_file); } fn_format(name,name,"","",4); -#if !defined(__WIN__) && !defined(__NETWARE__) +#if !defined(__WIN__) { MY_STAT stat_info; if (!my_stat(name,&stat_info,MYF(0))) @@ -954,7 +953,6 @@ static char *remove_end_comment(char *ptr) return ptr; } -#include <help_start.h> void my_print_default_files(const char *conf_file) { @@ -1034,8 +1032,6 @@ void print_defaults(const char *conf_file, const char **groups) --defaults-extra-file=# Read this file after the global files are read."); } -#include <help_end.h> - static int add_directory(MEM_ROOT *alloc, const char *dir, const char **dirs) { @@ -1150,10 +1146,6 @@ static const char **init_default_directories(MEM_ROOT *alloc) errors += add_directory(alloc, fname_buffer, dirs); } -#elif defined(__NETWARE__) - - errors += add_directory(alloc, "sys:/etc/", dirs); - #else errors += add_directory(alloc, "/etc/", dirs); @@ -1172,7 +1164,7 @@ static const char **init_default_directories(MEM_ROOT *alloc) /* Placeholder for --defaults-extra-file=<path> */ errors += add_directory(alloc, "", dirs); -#if !defined(__WIN__) && !defined(__NETWARE__) +#if !defined(__WIN__) errors += add_directory(alloc, "~/", dirs); #endif diff --git a/mysys/default_modify.c b/mysys/default_modify.c index b214a1df445..edf4907cd4b 100644 --- a/mysys/default_modify.c +++ b/mysys/default_modify.c @@ -223,11 +223,11 @@ int modify_defaults_file(const char *file_location, const char *option, if (my_fclose(cnf_file, MYF(MY_WME))) DBUG_RETURN(1); - my_free(file_buffer, MYF(0)); + my_free(file_buffer); DBUG_RETURN(0); err: - my_free(file_buffer, MYF(0)); + my_free(file_buffer); malloc_err: my_fclose(cnf_file, MYF(0)); DBUG_RETURN(1); /* out of resources */ diff --git a/mysys/errors.c b/mysys/errors.c index 37d33374fe1..9342ab2d2dd 100644 --- a/mysys/errors.c +++ b/mysys/errors.c @@ -18,7 +18,7 @@ #ifndef SHARED_LIBRARY -const char * NEAR globerrs[GLOBERRS]= +const char *globerrs[GLOBERRS]= { "Can't create/write to file '%s' (Errcode: %d)", "Error reading file '%s' (Errcode: %d)", diff --git a/mysys/hash.c b/mysys/hash.c index 39f3ad8d31e..f54ac1a4abb 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -67,8 +67,6 @@ static my_hash_value_type calc_hash(const HASH *hash, @param[in] get_key get the key for the hash @param[in] free_element pointer to the function that does cleanup - @param[in] CALLER_INFO_PROTO flag that define the behaviour - of the hash @return inidicates success or failure of initialization @retval 0 success @retval 1 failure @@ -77,7 +75,7 @@ my_bool _my_hash_init(HASH *hash, uint growth_size, CHARSET_INFO *charset, ulong size, size_t key_offset, size_t key_length, my_hash_get_key get_key, - void (*free_element)(void*), uint flags CALLER_INFO_PROTO) + void (*free_element)(void*), uint flags) { DBUG_ENTER("my_hash_init"); DBUG_PRINT("enter",("hash: 0x%lx size: %u", (long) hash, (uint) size)); diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c index 7fd10703871..c264d3ac4c5 100644 --- a/mysys/lf_alloc-pin.c +++ b/mysys/lf_alloc-pin.c @@ -472,7 +472,7 @@ void lf_alloc_destroy(LF_ALLOCATOR *allocator) uchar *tmp= anext_node(node); if (allocator->destructor) allocator->destructor(node); - my_free((void *)node, MYF(0)); + my_free(node); node= tmp; } lf_pinbox_destroy(&allocator->pinbox); diff --git a/mysys/lf_dynarray.c b/mysys/lf_dynarray.c index b1cdce698a9..0941c8762bb 100644 --- a/mysys/lf_dynarray.c +++ b/mysys/lf_dynarray.c @@ -57,10 +57,10 @@ static void recursive_free(void **alloc, int level) int i; for (i= 0; i < LF_DYNARRAY_LEVEL_LENGTH; i++) recursive_free(alloc[i], level-1); - my_free((void *)alloc, MYF(0)); + my_free(alloc); } else - my_free(alloc[-1], MYF(0)); + my_free(alloc[-1]); } void lf_dynarray_destroy(LF_DYNARRAY *array) @@ -115,7 +115,7 @@ void *_lf_dynarray_lvalue(LF_DYNARRAY *array, uint idx) if (my_atomic_casptr(ptr_ptr, &ptr, alloc)) ptr= alloc; else - my_free(alloc, MYF(0)); + my_free(alloc); } ptr_ptr= ((void **)ptr) + idx / dynarray_idxes_in_prev_level[i]; idx%= dynarray_idxes_in_prev_level[i]; @@ -139,7 +139,7 @@ void *_lf_dynarray_lvalue(LF_DYNARRAY *array, uint idx) if (my_atomic_casptr(ptr_ptr, &ptr, data)) ptr= data; else - my_free(alloc, MYF(0)); + my_free(alloc); } return ((uchar*)ptr) + array->size_of_element * idx; } diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c index f478196c7c8..9c51ff1766e 100644 --- a/mysys/lf_hash.c +++ b/mysys/lf_hash.c @@ -344,7 +344,7 @@ void lf_hash_destroy(LF_HASH *hash) if (el->hashnr & 1) lf_alloc_direct_free(&hash->alloc, el); /* normal node */ else - my_free((void *)el, MYF(0)); /* dummy node */ + my_free(el); /* dummy node */ el= (LF_SLIST *)next; } lf_alloc_destroy(&hash->alloc); @@ -489,7 +489,7 @@ static int initialize_bucket(LF_HASH *hash, LF_SLIST * volatile *node, dummy->keylen= 0; if ((cur= linsert(el, hash->charset, dummy, pins, LF_HASH_UNIQUE))) { - my_free((void *)dummy, MYF(0)); + my_free(dummy); dummy= cur; } my_atomic_casptr((void **)node, (void **)&tmp, dummy); diff --git a/mysys/list.c b/mysys/list.c index aaadd686365..e68fbf519d1 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((uchar*) root->data,MYF(0)); - my_free((uchar*) root,MYF(0)); + my_free(root->data); + my_free(root); root=next; } } diff --git a/mysys/mf_cache.c b/mysys/mf_cache.c index f0df0f3fa77..691532c0d80 100644 --- a/mysys/mf_cache.c +++ b/mysys/mf_cache.c @@ -71,8 +71,8 @@ my_bool open_cached_file(IO_CACHE *cache, const char* dir, const char *prefix, { DBUG_RETURN(0); } - my_free(cache->dir, MYF(MY_ALLOW_ZERO_PTR)); - my_free(cache->prefix,MYF(MY_ALLOW_ZERO_PTR)); + my_free(cache->dir); + my_free(cache->prefix); DBUG_RETURN(1); } @@ -110,12 +110,12 @@ void close_cached_file(IO_CACHE *cache) if (cache->file_name) { (void) my_delete(cache->file_name,MYF(MY_WME | ME_NOINPUT)); - my_free(cache->file_name,MYF(0)); + my_free(cache->file_name); } #endif } - my_free(cache->dir,MYF(MY_ALLOW_ZERO_PTR)); - my_free(cache->prefix,MYF(MY_ALLOW_ZERO_PTR)); + my_free(cache->dir); + my_free(cache->prefix); } DBUG_VOID_RETURN; } diff --git a/mysys/mf_dirname.c b/mysys/mf_dirname.c index 1b428ded751..5a9440483e4 100644 --- a/mysys/mf_dirname.c +++ b/mysys/mf_dirname.c @@ -40,11 +40,7 @@ size_t dirname_length(const char *name) continue; } #endif - if (*pos == FN_LIBCHAR || *pos == '/' -#ifdef FN_C_AFTER_DIR - || *pos == FN_C_AFTER_DIR || *pos == FN_C_AFTER_DIR_2 -#endif - ) + if (*pos == FN_LIBCHAR || *pos == '/') gpos=pos; } return (size_t) (gpos+1-(char*) name); @@ -88,8 +84,7 @@ size_t dirname_part(char *to, const char *name, size_t *to_res_length) from_end Pointer at end of filename (normally end \0) IMPLEMENTATION - If MSDOS converts '/' to '\' - If VMS converts '<' to '[' and '>' to ']' + If Windows converts '/' to '\' Adds a FN_LIBCHAR to end if the result string if there isn't one and the last isn't dev_char. Copies data from 'from' until ASCII(0) for until from == from_end @@ -118,18 +113,12 @@ char *convert_dirname(char *to, const char *from, const char *from_end) if (!from_end || (from_end - from) > FN_REFLEN-2) from_end=from+FN_REFLEN -2; -#if FN_LIBCHAR != '/' || defined(FN_C_BEFORE_DIR_2) +#if FN_LIBCHAR != '/' { for (; from != from_end && *from ; from++) { if (*from == '/') *to++= FN_LIBCHAR; -#ifdef FN_C_BEFORE_DIR_2 - else if (*from == FN_C_BEFORE_DIR_2) - *to++= FN_C_BEFORE_DIR; - else if (*from == FN_C_AFTER_DIR_2) - *to++= FN_C_AFTER_DIR; -#endif else { #ifdef BACKSLASH_MBTAIL diff --git a/mysys/mf_fn_ext.c b/mysys/mf_fn_ext.c index da7fac3de73..c872f2993c4 100644 --- a/mysys/mf_fn_ext.c +++ b/mysys/mf_fn_ext.c @@ -39,7 +39,7 @@ char *fn_ext(const char *name) DBUG_ENTER("fn_ext"); DBUG_PRINT("mfunkt",("name: '%s'",name)); -#if defined(FN_DEVCHAR) || defined(FN_C_AFTER_DIR) || defined(BASKSLASH_MBTAIL) +#if defined(FN_DEVCHAR) || defined(BASKSLASH_MBTAIL) { char buff[FN_REFLEN]; size_t res_length; diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index 620ac667a8b..daacc08044b 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -1831,7 +1831,7 @@ 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((uchar*) info->buffer,MYF(MY_WME)); + my_free(info->buffer); info->buffer=info->read_pos=(uchar*) 0; } if (info->type == SEQ_READ_APPEND) @@ -1917,7 +1917,7 @@ int main(int argc, char** argv) total_bytes += 4+block_size; } close_file(&sra_cache); - my_free(block,MYF(MY_WME)); + my_free(block); if (!my_stat(fname,&status,MYF(MY_WME))) die("%s failed to stat, but I had just closed it,\ wonder how that happened"); diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 9cbe3a21bce..c42c3d469e6 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -252,7 +252,7 @@ static void test_key_cache(KEY_CACHE *keycache, #if defined(KEYCACHE_DEBUG_LOG) static FILE *keycache_debug_log=NULL; -static void keycache_debug_print _VARARGS((const char *fmt,...)); +static void keycache_debug_print(const char *fmt,...); #define KEYCACHE_DEBUG_OPEN \ if (!keycache_debug_log) \ { \ @@ -446,7 +446,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, if ((keycache->block_root= (BLOCK_LINK*) my_malloc(length, MYF(0)))) break; - my_large_free(keycache->block_mem, MYF(0)); + my_large_free(keycache->block_mem); keycache->block_mem= 0; } if (blocks < 8) @@ -521,12 +521,12 @@ err: keycache->blocks= 0; if (keycache->block_mem) { - my_large_free((uchar*) keycache->block_mem, MYF(0)); + my_large_free((uchar*) keycache->block_mem); keycache->block_mem= NULL; } if (keycache->block_root) { - my_free((uchar*) keycache->block_root, MYF(0)); + my_free(keycache->block_root); keycache->block_root= NULL; } my_errno= error; @@ -747,9 +747,9 @@ void end_key_cache(KEY_CACHE *keycache, my_bool cleanup) { if (keycache->block_mem) { - my_large_free((uchar*) keycache->block_mem, MYF(0)); + my_large_free((uchar*) keycache->block_mem); keycache->block_mem= NULL; - my_free((uchar*) keycache->block_root, MYF(0)); + my_free(keycache->block_root); keycache->block_root= NULL; } keycache->disk_blocks= -1; @@ -4080,7 +4080,7 @@ restart: #endif err: if (cache != cache_buff) - my_free((uchar*) cache, MYF(0)); + my_free(cache); 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 999e8cc7975..ee4ad025b0b 100644 --- a/mysys/mf_keycaches.c +++ b/mysys/mf_keycaches.c @@ -71,7 +71,7 @@ typedef struct st_safe_hash_with_default static void safe_hash_entry_free(SAFE_HASH_ENTRY *entry) { DBUG_ENTER("free_assign_entry"); - my_free((uchar*) entry, MYF(0)); + my_free(entry); DBUG_VOID_RETURN; } @@ -234,7 +234,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const uchar *key, uint length, if (my_hash_insert(&hash->hash, (uchar*) entry)) { /* This can only happen if hash got out of memory */ - my_free((char*) entry, MYF(0)); + my_free(entry); error= 1; goto end; } diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c index 86fd61537e7..c6e6a3a429e 100644 --- a/mysys/mf_pack.c +++ b/mysys/mf_pack.c @@ -18,13 +18,8 @@ #ifdef HAVE_PWD_H #include <pwd.h> #endif -#ifdef VMS -#include <rms.h> -#include <iodef.h> -#include <descrip.h> -#endif /* VMS */ -static char * NEAR_F expand_tilde(char * *path); +static char * expand_tilde(char **path); /* Pack a dirname ; Changes HOME to ~/ and current dev to ./ */ /* from is a dirname (from dirname() ?) ending with FN_LIBCHAR */ @@ -300,8 +295,7 @@ size_t normalize_dirname(char *to, const char *from) /* Despite the name, this actually converts the name to the system's - format (TODO: rip out the non-working VMS stuff and name this - properly). + format (TODO: name this properly). */ (void) intern_filename(buff, from); length= strlen(buff); /* Fix that '/' is last */ @@ -377,7 +371,7 @@ size_t unpack_dirname(char * to, const char *from) /* Expand tilde to home or user-directory */ /* Path is reset to point at FN_LIBCHAR after ~xxx */ -static char * NEAR_F expand_tilde(char * *path) +static char * expand_tilde(char **path) { if (path[0][0] == FN_LIBCHAR) return home_dir; /* ~/ expanded to home */ @@ -443,73 +437,10 @@ size_t unpack_filename(char * to, const char *from) /* Used before system command's like open(), create() .. */ /* Returns used length of to; total length should be FN_REFLEN */ -size_t system_filename(char * to, const char *from) +size_t system_filename(char *to, const char *from) { -#ifndef FN_C_BEFORE_DIR return (size_t) (strmake(to,from,FN_REFLEN-1)-to); -#else /* VMS */ - - /* change 'dev:lib/xxx' to 'dev:[lib]xxx' */ - /* change 'dev:xxx' to 'dev:xxx' */ - /* change './xxx' to 'xxx' */ - /* change './lib/' or lib/ to '[.lib]' */ - /* change '/x/y/z to '[x.y]x' */ - /* change 'dev:/x' to 'dev:[000000]x' */ - - int libchar_found; - size_t length; - char * to_pos,from_pos,pos; - char buff[FN_REFLEN]; - DBUG_ENTER("system_filename"); - - libchar_found=0; - (void) strmov(buff,from); /* If to == from */ - from_pos= buff; - if ((pos=strrchr(from_pos,FN_DEVCHAR))) /* Skip device part */ - { - pos++; - to_pos=strnmov(to,from_pos,(size_t) (pos-from_pos)); - from_pos=pos; - } - else - to_pos=to; - - if (from_pos[0] == FN_CURLIB && from_pos[1] == FN_LIBCHAR) - from_pos+=2; /* Skip './' */ - if (strchr(from_pos,FN_LIBCHAR)) - { - *(to_pos++) = FN_C_BEFORE_DIR; - if (strinstr(from_pos,FN_ROOTDIR) == 1) - { - from_pos+=strlen(FN_ROOTDIR); /* Actually +1 but... */ - if (! strchr(from_pos,FN_LIBCHAR)) - { /* No dir, use [000000] */ - to_pos=strmov(to_pos,FN_C_ROOT_DIR); - libchar_found++; - } - } - else - *(to_pos++)=FN_C_DIR_SEP; /* '.' gives current dir */ - - while ((pos=strchr(from_pos,FN_LIBCHAR))) - { - if (libchar_found++) - *(to_pos++)=FN_C_DIR_SEP; /* Add '.' between dirs */ - if (strinstr(from_pos,FN_PARENTDIR) == 1 && - 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_t) (pos-from_pos)); - from_pos=pos+1; - } - *(to_pos++)=FN_C_AFTER_DIR; - } - length= (size_t) (strmov(to_pos,from_pos)-to); - DBUG_PRINT("exit",("name: '%s'",to)); - DBUG_RETURN(length); -#endif -} /* system_filename */ - +} /* Fix a filename to intern (UNIX format) */ diff --git a/mysys/mf_path.c b/mysys/mf_path.c index d51cac732f5..92cb62e6827 100644 --- a/mysys/mf_path.c +++ b/mysys/mf_path.c @@ -78,9 +78,6 @@ char * my_path(char * to, const char *progname, #define F_OK 0 #define PATH_SEP ';' #define PROGRAM_EXTENSION ".exe" -#elif defined(__NETWARE__) -#define PATH_SEP ';' -#define PROGRAM_EXTENSION ".nlm" #else #define PATH_SEP ':' #endif diff --git a/mysys/mf_sort.c b/mysys/mf_sort.c index 686ebbc1d14..a3e7465ead0 100644 --- a/mysys/mf_sort.c +++ b/mysys/mf_sort.c @@ -27,7 +27,7 @@ void my_string_ptr_sort(uchar *base, uint items, size_t size) (ptr= (uchar**) my_malloc(items*sizeof(char*),MYF(0)))) { radixsort_for_str_ptr((uchar**) base,items,size,ptr); - my_free((uchar*) ptr,MYF(0)); + my_free(ptr); } else #endif diff --git a/mysys/mf_tempdir.c b/mysys/mf_tempdir.c index 5633182ab3a..c84987cfc96 100644 --- a/mysys/mf_tempdir.c +++ b/mysys/mf_tempdir.c @@ -16,7 +16,7 @@ #include "mysys_priv.h" #include <m_string.h> -#if defined( __WIN__) || defined(__NETWARE__) +#if defined(__WIN__) #define DELIM ';' #else #define DELIM ':' @@ -36,7 +36,7 @@ my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist) { /* Get default temporary directory */ pathlist=getenv("TMPDIR"); /* Use this if possible */ -#if defined( __WIN__) || defined(__NETWARE__) +#if defined(__WIN__) if (!pathlist) pathlist=getenv("TEMP"); if (!pathlist) @@ -88,7 +88,7 @@ void free_tmpdir(MY_TMPDIR *tmpdir) if (!tmpdir->full_list.elements) return; for (i=0; i<=tmpdir->max; i++) - my_free(tmpdir->list[i], MYF(0)); + my_free(tmpdir->list[i]); delete_dynamic(&tmpdir->full_list); mysql_mutex_destroy(&tmpdir->mutex); } diff --git a/mysys/mf_tempfile.c b/mysys/mf_tempfile.c index 40016210de4..e85124fb4c3 100644 --- a/mysys/mf_tempfile.c +++ b/mysys/mf_tempfile.c @@ -100,16 +100,7 @@ File create_temp_file(char *to, const char *dir, const char *prefix, my_errno= tmp; } -#elif defined(_ZTC__) - if (!dir) - dir=getenv("TMPDIR"); - if ((res=tempnam((char*) dir,(char *) prefix))) - { - strmake(to,res,FN_REFLEN-1); - (*free)(res); - file=my_create(to, 0, mode | O_EXCL | O_NOFOLLOW, MyFlags); - } -#elif defined(HAVE_MKSTEMP) && !defined(__NETWARE__) +#elif defined(HAVE_MKSTEMP) { char prefix_buff[30]; uint pfx_len; @@ -143,9 +134,7 @@ File create_temp_file(char *to, const char *dir, const char *prefix, } #elif defined(HAVE_TEMPNAM) { -#if !defined(__NETWARE__) extern char **environ; -#endif char *res,**old_env,*temp_env[1]; if (dir && !dir[0]) @@ -154,14 +143,14 @@ File create_temp_file(char *to, const char *dir, const char *prefix, to[1]= 0; dir=to; } -#if !defined(__NETWARE__) + old_env= (char**) environ; if (dir) { /* Don't use TMPDIR if dir is given */ environ=(const char**) temp_env; temp_env[0]=0; } -#endif + if ((res=tempnam((char*) dir, (char*) prefix))) { strmake(to,res,FN_REFLEN-1); @@ -176,9 +165,8 @@ File create_temp_file(char *to, const char *dir, const char *prefix, { DBUG_PRINT("error",("Got error: %d from tempnam",errno)); } -#if !defined(__NETWARE__) + environ=(const char**) old_env; -#endif } #else #error No implementation found for create_temp_file diff --git a/mysys/mf_unixpath.c b/mysys/mf_unixpath.c index 75f8de14879..ee81aae4584 100644 --- a/mysys/mf_unixpath.c +++ b/mysys/mf_unixpath.c @@ -16,10 +16,15 @@ #include "mysys_priv.h" #include <m_string.h> - /* convert filename to unix style filename */ - /* If MSDOS converts '\' to '/' */ +/** + Convert filename to unix style filename. -void to_unix_path(char * to __attribute__((unused))) + @remark On Windows, converts '\' to '/'. + + @param to A pathname. +*/ + +void to_unix_path(char *to __attribute__((unused))) { #if FN_LIBCHAR != '/' { diff --git a/mysys/mf_util.c b/mysys/mf_util.c deleted file mode 100644 index 248b72b8748..00000000000 --- a/mysys/mf_util.c +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* Utilities with are missing on some systems */ - -#include "mysys_priv.h" -#ifdef __ZTC__ -#include <dos.h> -#endif - -#ifdef __ZTC__ - - /* On ZORTECH C we don't have a getpid() call */ - -int getpid(void) -{ - return (int) _psp; -} - -#ifndef M_IC80386 - - /* Define halloc and hfree in as in MSC */ - -void * __CDECL halloc(long count,size_t length) -{ - return (void*) MK_FP(dos_alloc((uint) ((count*length+15) >> 4)),0); -} - -void __CDECL hfree(void *ptr) -{ - dos_free(FP_SEG(ptr)); -} - -#endif /* M_IC80386 */ -#endif /* __ZTC__ */ diff --git a/mysys/mf_wfile.c b/mysys/mf_wfile.c index 4a4fb466600..95c4c006b2c 100644 --- a/mysys/mf_wfile.c +++ b/mysys/mf_wfile.c @@ -118,7 +118,6 @@ found: void wf_end(WF_PACK *buffer) { DBUG_ENTER("wf_end"); - if (buffer) - my_free(buffer, MYF(0)); + my_free(buffer); DBUG_VOID_RETURN; } /* wf_end */ diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c index 19e51880209..903826dd975 100644 --- a/mysys/my_alloc.c +++ b/mysys/my_alloc.c @@ -120,7 +120,7 @@ void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size, { /* remove block from the list and free it */ *prev= mem->next; - my_free(mem, MYF(0)); + my_free(mem); } else prev= &mem->next; @@ -362,13 +362,13 @@ void free_root(MEM_ROOT *root, myf MyFlags) { old=next; next= next->next ; if (old != root->pre_alloc) - my_free(old,MYF(0)); + my_free(old); } for (next=root->free ; next ;) { old=next; next= next->next; if (old != root->pre_alloc) - my_free(old,MYF(0)); + my_free(old); } root->used=root->free=0; if (root->pre_alloc) diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c index fc5d1dba217..3de05fa8664 100644 --- a/mysys/my_bitmap.c +++ b/mysys/my_bitmap.c @@ -150,7 +150,7 @@ void bitmap_free(MY_BITMAP *map) if (map->mutex) mysql_mutex_destroy(map->mutex); #endif - my_free((char*) map->bitmap, MYF(0)); + my_free(map->bitmap); map->bitmap=0; } DBUG_VOID_RETURN; diff --git a/mysys/my_clock.c b/mysys/my_clock.c index d17f26ed316..da04feb462f 100644 --- a/mysys/my_clock.c +++ b/mysys/my_clock.c @@ -15,14 +15,14 @@ #include "my_global.h" -#if !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__NETWARE__) +#if !defined(_MSC_VER) && !defined(__BORLANDC__) #include "mysys_priv.h" #include <sys/times.h> #endif long my_clock(void) { -#if !defined(__WIN__) && !defined(__NETWARE__) +#if !defined(__WIN__) struct tms tmsbuf; (void) times(&tmsbuf); return (tmsbuf.tms_utime + tmsbuf.tms_stime); diff --git a/mysys/my_compress.c b/mysys/my_compress.c index a3d9d56915e..360390d376a 100644 --- a/mysys/my_compress.c +++ b/mysys/my_compress.c @@ -51,7 +51,7 @@ my_bool my_compress(uchar *packet, size_t *len, size_t *complen) if (!compbuf) DBUG_RETURN(*complen ? 0 : 1); memcpy(packet,compbuf,*len); - my_free(compbuf,MYF(MY_WME)); + my_free(compbuf); } DBUG_RETURN(0); } @@ -73,14 +73,14 @@ uchar *my_compress_alloc(const uchar *packet, size_t *len, size_t *complen) if (res != Z_OK) { - my_free(compbuf, MYF(MY_WME)); + my_free(compbuf); return 0; } if (*complen >= *len) { *complen= 0; - my_free(compbuf, MYF(MY_WME)); + my_free(compbuf); DBUG_PRINT("note",("Packet got longer on compression; Not compressed")); return 0; } @@ -125,11 +125,11 @@ my_bool my_uncompress(uchar *packet, size_t len, size_t *complen) if (error != Z_OK) { /* Probably wrong packet */ DBUG_PRINT("error",("Can't uncompress packet, error: %d",error)); - my_free(compbuf, MYF(MY_WME)); + my_free(compbuf); DBUG_RETURN(1); } memcpy(packet, compbuf, *complen); - my_free(compbuf, MYF(MY_WME)); + my_free(compbuf); } else *complen= len; @@ -250,7 +250,7 @@ int unpackfrm(uchar **unpack_data, size_t *unpack_len, if (my_uncompress(data, complen, &orglen)) { - my_free(data, MYF(0)); + my_free(data); DBUG_RETURN(3); } diff --git a/mysys/my_copy.c b/mysys/my_copy.c index d38507c111a..878aebd3684 100644 --- a/mysys/my_copy.c +++ b/mysys/my_copy.c @@ -103,10 +103,10 @@ int my_copy(const char *from, const char *to, myf MyFlags) if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat) DBUG_RETURN(0); /* File copyed but not stat */ res= chmod(to, stat_buff.st_mode & 07777); /* Copy modes */ -#if !defined(__WIN__) && !defined(__NETWARE__) +#if !defined(__WIN__) res= chown(to, stat_buff.st_uid,stat_buff.st_gid); /* Copy ownership */ #endif -#if !defined(VMS) && !defined(__ZTC__) + if (MyFlags & MY_COPYTIME) { struct utimbuf timep; @@ -114,7 +114,7 @@ int my_copy(const char *from, const char *to, myf MyFlags) timep.modtime = stat_buff.st_mtime; (void) utime((char*) to, &timep); /* last accessed and modified times */ } -#endif + DBUG_RETURN(0); } diff --git a/mysys/my_delete.c b/mysys/my_delete.c index edee1c4e875..4a23fedb5ab 100644 --- a/mysys/my_delete.c +++ b/mysys/my_delete.c @@ -93,23 +93,33 @@ int nt_share_delete(const char *name, myf MyFlags) name, buf, errno)); break; } - + if (errno == ERROR_FILE_NOT_FOUND) { - my_errno= ENOENT; // marking, that `name' doesn't exist + my_errno= ENOENT; // marking, that `name' doesn't exist } else if (errno == 0) { - if (DeleteFile(buf)) - DBUG_RETURN(0); - else if ((my_errno= GetLastError()) == 0) - my_errno= ENOENT; // marking, that `buf' doesn't exist - } else - my_errno= errno; - + if (DeleteFile(buf)) + DBUG_RETURN(0); + /* + The below is more complicated than necessary. For some reason, the + assignment to my_errno clears the error number, which is retrieved + by GetLastError() (VC2005EE). Assigning to errno first, allows to + retrieve the correct value. + */ + errno= GetLastError(); + if (errno == 0) + my_errno= ENOENT; // marking, that `buf' doesn't exist + else + my_errno= errno; + } + else + my_errno= errno; + if (MyFlags & (MY_FAE+MY_WME)) - my_error(EE_DELETE, MYF(ME_BELL + ME_WAITTANG + (MyFlags & ME_NOINPUT)), - name, my_errno); + my_error(EE_DELETE, MYF(ME_BELL + ME_WAITTANG + (MyFlags & ME_NOINPUT)), + name, my_errno); DBUG_RETURN(-1); } #endif diff --git a/mysys/my_error.c b/mysys/my_error.c index e2523a39d0b..fa62cc604b6 100644 --- a/mysys/my_error.c +++ b/mysys/my_error.c @@ -211,7 +211,7 @@ int my_error_register(const char** (*get_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((uchar*)meh_p, MYF(0)); + my_free(meh_p); return 1; } @@ -267,7 +267,7 @@ const char **my_error_unregister(int first, int last) /* Save the return value and free the header. */ errmsgs= meh_p->get_errmsgs(); - my_free((uchar*) meh_p, MYF(0)); + my_free(meh_p); return errmsgs; } @@ -282,7 +282,7 @@ void my_error_unregister_all(void) /* We need this ptr, but we're about to free its container, so save it. */ saved_next= cursor->meh_next; - my_free((uchar*) cursor, MYF(0)); + my_free(cursor); } my_errmsgs_globerrs.meh_next= NULL; /* Freed in first iteration above. */ diff --git a/mysys/my_file.c b/mysys/my_file.c index a31673b31bc..e4b7cd7779f 100644 --- a/mysys/my_file.c +++ b/mysys/my_file.c @@ -127,7 +127,7 @@ void my_free_open_file_info() /* Copy data back for my_print_open_files */ memcpy((char*) my_file_info_default, my_file_info, sizeof(*my_file_info_default)* MY_NFILE); - my_free((char*) my_file_info, MYF(0)); + my_free(my_file_info); my_file_info= my_file_info_default; my_file_limit= MY_NFILE; } diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c index 3f2bc08df65..861e4380690 100644 --- a/mysys/my_fopen.c +++ b/mysys/my_fopen.c @@ -117,7 +117,7 @@ int my_fclose(FILE *fd, myf MyFlags) if ((uint) file < my_file_limit && my_file_info[file].type != UNOPEN) { my_file_info[file].type = UNOPEN; - my_free(my_file_info[file].name, MYF(MY_ALLOW_ZERO_PTR)); + my_free(my_file_info[file].name); } mysql_mutex_unlock(&THR_LOCK_open); DBUG_RETURN(err); diff --git a/mysys/my_gethwaddr.c b/mysys/my_gethwaddr.c index bfbe205be39..9ca22f2201e 100644 --- a/mysys/my_gethwaddr.c +++ b/mysys/my_gethwaddr.c @@ -196,7 +196,7 @@ my_bool my_gethwaddr(uchar *to) /* Clean up memory allocation. */ if (pAdapterAddresses != &adapterAddresses) - my_free(pAdapterAddresses, 0); + my_free(pAdapterAddresses); return return_val; } diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 30f4888cd98..7443405f97c 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -595,8 +595,7 @@ static int setval(const struct my_option *opts, void *value, char *argument, case GET_STR_ALLOC: if (argument == enabled_my_option) break; /* string options don't use this default of "1" */ - if ((*((char**) value))) - my_free((*(char**) value), MYF(MY_WME | MY_FAE)); + my_free(*((char**) value)); if (!(*((char**) value)= my_strdup(argument, MYF(MY_WME)))) { res= EXIT_OUT_OF_MEMORY; @@ -1054,8 +1053,9 @@ static void init_one_value(const struct my_option *option, void *variable, */ if ((char*) (intptr) value) { - my_free((*(char**) variable), MYF(MY_ALLOW_ZERO_PTR)); - *((char**) variable)= my_strdup((char*) (intptr) value, MYF(MY_WME)); + char **pstr= (char **) variable; + my_free(*pstr); + *pstr= my_strdup((char*) (intptr) value, MYF(MY_WME)); } break; default: /* dummy default to avoid compiler warnings */ @@ -1080,7 +1080,7 @@ static void fini_one_value(const struct my_option *option, void *variable, DBUG_ENTER("fini_one_value"); switch ((option->var_type & GET_TYPE_MASK)) { case GET_STR_ALLOC: - my_free((*(char**) variable), MYF(MY_ALLOW_ZERO_PTR)); + my_free(*((char**) variable)); *((char**) variable)= NULL; break; default: /* dummy default to avoid compiler warnings */ @@ -1147,8 +1147,6 @@ static uint print_name(const struct my_option *optp) Print help for all options and variables. */ -#include <help_start.h> - void my_print_help(const struct my_option *options) { uint col, name_space= 22, comment_space= 57; @@ -1330,5 +1328,3 @@ void my_print_variables(const struct my_option *options) } } } - -#include <help_end.h> diff --git a/mysys/my_getsystime.c b/mysys/my_getsystime.c index ea12f73fe3d..cc5d1b83efb 100644 --- a/mysys/my_getsystime.c +++ b/mysys/my_getsystime.c @@ -25,10 +25,6 @@ #include "mysys_priv.h" #include "my_static.h" -#ifdef __NETWARE__ -#include <nks/time.h> -#endif - ulonglong my_getsystime() { #ifdef HAVE_CLOCK_GETTIME @@ -45,10 +41,6 @@ ulonglong my_getsystime() query_performance_frequency) + query_performance_offset); } return 0; -#elif defined(__NETWARE__) - NXTime_t tm; - NXGetTime(NX_SINCE_1970, NX_NSECONDS, &tm); - return (ulonglong)tm/100; #else /* TODO: check for other possibilities for hi-res timestamping */ struct timeval tv; diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c index 4182ea9826f..ace14c8a3c9 100644 --- a/mysys/my_getwd.c +++ b/mysys/my_getwd.c @@ -72,16 +72,6 @@ int my_getwd(char * buf, size_t size, myf MyFlags) getwd(pathname); strmake(buf,pathname,size-1); } -#elif defined(VMS) - if (size < 2) - DBUG_RETURN(-1); - if (!getcwd(buf,size-2,1) && MyFlags & MY_WME) - { - my_errno=errno; - my_error(EE_GETWD,MYF(ME_BELL+ME_WAITTANG),errno); - DBUG_RETURN(-1); - } - intern_filename(buf,buf); #else #error "No way to get current directory" #endif @@ -103,27 +93,12 @@ int my_setwd(const char *dir, myf MyFlags) int res; 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=(char *) dir; if (! dir[0] || (dir[0] == FN_LIBCHAR && dir[1] == 0)) dir=FN_ROOTDIR; -#ifdef VMS - { - pos=strmov(buff,dir); - if (pos[-1] != FN_LIBCHAR) - { - pos[0]=FN_LIBCHAR; /* Mark as directory */ - pos[1]=0; - } - system_filename(buff,buff); /* Change to VMS format */ - dir=buff; - } -#endif /* VMS */ if ((res=chdir((char*) dir)) != 0) { my_errno=errno; diff --git a/mysys/my_init.c b/mysys/my_init.c index 5bda2cb03ac..dbf1bfe761c 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -19,10 +19,6 @@ #include <m_string.h> #include <m_ctype.h> #include <signal.h> -#ifdef VMS -#include <my_static.c> -#include <m_ctype.h> -#endif #ifdef __WIN__ #ifdef _MSC_VER #include <locale.h> @@ -36,11 +32,6 @@ static my_bool win32_init_tcp_ip(); #else #define my_win_init() #endif -#ifdef __NETWARE__ -static void netware_init(); -#else -#define netware_init() -#endif my_bool my_init_done= 0; /** True if @c my_basic_init() has been called. */ @@ -84,14 +75,12 @@ my_bool my_basic_init(void) my_umask= 0660; /* Default umask for new files */ my_umask_dir= 0700; /* Default umask for new directories */ -#ifndef VMS /* Default creation of new files */ if ((str= getenv("UMASK")) != 0) my_umask= (int) (atoi_octal(str) | 0600); /* Default creation of new dir's */ if ((str= getenv("UMASK_DIR")) != 0) my_umask_dir= (int) (atoi_octal(str) | 0700); -#endif init_glob_errs(); @@ -109,7 +98,6 @@ my_bool my_basic_init(void) #if defined(THREAD) && defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX) fastmutex_global_init(); /* Must be called early */ #endif - netware_init(); #ifdef THREAD #if defined(HAVE_PTHREAD_INIT) pthread_init(); /* Must be called before DBUG_ENTER */ @@ -141,6 +129,7 @@ my_bool my_init(void) { if (my_init_done) return 0; + my_init_done= 1; if (my_basic_init()) @@ -149,7 +138,7 @@ my_bool my_init(void) #ifdef THREAD if (my_thread_global_init()) return 1; -#if !defined( __WIN__) && !defined(__NETWARE__) +#if !defined(__WIN__) sigfillset(&my_signals); /* signals blocked by mf_brkhant */ #endif #endif /* THREAD */ @@ -157,9 +146,6 @@ my_bool my_init(void) DBUG_ENTER("my_init"); DBUG_PROCESS((char*) (my_progname ? my_progname : "unknown")); my_win_init(); -#ifdef VMS - init_ctype(); /* Stupid linker don't link _ctype.c */ -#endif DBUG_PRINT("exit", ("home: '%s'", home_dir)); #ifdef __WIN__ win32_init_tcp_ip(); @@ -238,12 +224,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", rus.ru_msgsnd, rus.ru_msgrcv, rus.ru_nsignals, rus.ru_nvcsw, rus.ru_nivcsw); #endif -#if defined(__NETWARE__) && !defined(__WIN__) - fprintf(info_file,"\nRun time: %.1f\n",(double) clock()/CLOCKS_PER_SEC); -#endif -#if defined(SAFEMALLOC) - TERMINATE(stderr, (infoflag & MY_GIVE_INFO) != 0); -#elif defined(__WIN__) && defined(_MSC_VER) +#if defined(__WIN__) && defined(_MSC_VER) _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR ); _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE ); @@ -254,10 +235,6 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", _CrtDumpMemoryLeaks(); #endif } - else if (infoflag & MY_CHECK_ERROR) - { - TERMINATE(stderr, 0); /* Print memory leaks on screen */ - } if (!(infoflag & MY_DONT_FREE_DBUG)) { @@ -280,6 +257,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", if (have_tcpip) WSACleanup(); #endif /* __WIN__ */ + my_init_done=0; my_basic_init_done= 0; } /* my_end */ @@ -528,60 +506,6 @@ static my_bool win32_init_tcp_ip() } #endif /* __WIN__ */ - -#ifdef __NETWARE__ -/* - Basic initialisation for netware -*/ - -static void netware_init() -{ - char cwd[PATH_MAX], *name; - - DBUG_ENTER("netware_init"); - - /* init only if we are not a client library */ - if (my_progname) - { -#if SUPPORTED_BY_LIBC /* Removed until supported in Libc */ - struct termios tp; - /* Disable control characters */ - tcgetattr(STDIN_FILENO, &tp); - tp.c_cc[VINTR] = _POSIX_VDISABLE; - tp.c_cc[VEOF] = _POSIX_VDISABLE; - tp.c_cc[VSUSP] = _POSIX_VDISABLE; - tcsetattr(STDIN_FILENO, TCSANOW, &tp); -#endif /* SUPPORTED_BY_LIBC */ - - /* With stdout redirection */ - if (!isatty(STDOUT_FILENO)) - { - setscreenmode(SCR_AUTOCLOSE_ON_EXIT); /* auto close the screen */ - } - else - { - setscreenmode(SCR_NO_MODE); /* keep the screen up */ - } - - /* Parse program name and change to base format */ - name= (char*) my_progname; - for (; *name; name++) - { - if (*name == '\\') - { - *name = '/'; - } - else - { - *name = tolower(*name); - } - } - } - - DBUG_VOID_RETURN; -} -#endif /* __NETWARE__ */ - #ifdef HAVE_PSI_INTERFACE #if !defined(HAVE_PREAD) && !defined(_WIN32) diff --git a/mysys/my_largepage.c b/mysys/my_largepage.c index e65d3a0a5f5..9f5ab01a2b7 100644 --- a/mysys/my_largepage.c +++ b/mysys/my_largepage.c @@ -27,7 +27,7 @@ static uint my_get_large_page_size_int(void); static uchar* my_large_malloc_int(size_t size, myf my_flags); -static my_bool my_large_free_int(uchar* ptr, myf my_flags); +static my_bool my_large_free_int(uchar* ptr); /* Gets the size of large pages from the OS */ @@ -70,7 +70,7 @@ uchar* my_large_malloc(size_t size, myf my_flags) to my_free_lock() in case of failure */ -void my_large_free(uchar* ptr, myf my_flags __attribute__((unused))) +void my_large_free(uchar* ptr) { DBUG_ENTER("my_large_free"); @@ -79,9 +79,8 @@ void my_large_free(uchar* ptr, myf my_flags __attribute__((unused))) my_large_malloc_int(), i.e. my_malloc_lock() was used so we should free it with my_free_lock() */ - if (!my_use_large_pages || !my_large_page_size || - !my_large_free_int(ptr, my_flags)) - my_free_lock(ptr, my_flags); + if (!my_use_large_pages || !my_large_page_size || !my_large_free_int(ptr)) + my_free_lock(ptr); DBUG_VOID_RETURN; } @@ -157,7 +156,7 @@ uchar* my_large_malloc_int(size_t size, myf my_flags) /* Linux-specific large pages deallocator */ -my_bool my_large_free_int(uchar *ptr, myf my_flags __attribute__((unused))) +my_bool my_large_free_int(uchar *ptr) { DBUG_ENTER("my_large_free_int"); DBUG_RETURN(shmdt(ptr) == 0); diff --git a/mysys/my_lib.c b/mysys/my_lib.c index 0113d1498df..890ff0b5dd1 100644 --- a/mysys/my_lib.c +++ b/mysys/my_lib.c @@ -14,7 +14,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* TODO: check for overun of memory for names. */ -/* Convert MSDOS-TIME to standar time_t (still needed?) */ #include "mysys_priv.h" #include <m_string.h> @@ -41,11 +40,6 @@ # endif # endif #endif -#ifdef VMS -#include <rms.h> -#include <iodef.h> -#include <descrip.h> -#endif #if defined(THREAD) && defined(HAVE_READDIR_R) #define READDIR(A,B,C) ((errno=readdir_r(A,B,&C)) != 0 || !C) @@ -77,7 +71,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((uchar*) buffer,MYF(0)); + my_free(buffer); } DBUG_VOID_RETURN; } /* my_dirend */ @@ -131,7 +125,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((uchar*) buffer,MYF(0)); + my_free(buffer); goto error; } init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE); @@ -199,9 +193,6 @@ MY_DIR *my_dir(const char *path, myf MyFlags) /* * Convert from directory name to filename. - * On VMS: - * xyzzy:[mukesh.emacs] => xyzzy:[mukesh]emacs.dir.1 - * xyzzy:[mukesh] => xyzzy:[000000]mukesh.dir.1 * On UNIX, it's simple: just make sure there is a terminating / * Returns pointer to dst; @@ -209,11 +200,8 @@ MY_DIR *my_dir(const char *path, myf MyFlags) char * directory_file_name (char * dst, const char *src) { -#ifndef VMS - /* Process as Unix format: just remove test the final slash. */ - - char * end; + char *end; if (src[0] == 0) src= (char*) "."; /* Use empty as current */ @@ -224,125 +212,7 @@ char * directory_file_name (char * dst, const char *src) end[1]='\0'; } return dst; - -#else /* VMS */ - - long slen; - long rlen; - char * ptr, rptr; - char bracket; - struct FAB fab = cc$rms_fab; - struct NAM nam = cc$rms_nam; - char esa[NAM$C_MAXRSS]; - - if (! src[0]) - src="[.]"; /* Empty is == current dir */ - - slen = strlen (src) - 1; - if (src[slen] == FN_C_AFTER_DIR || src[slen] == FN_C_AFTER_DIR_2 || - src[slen] == FN_DEVCHAR) - { - /* VMS style - convert [x.y.z] to [x.y]z, [x] to [000000]x */ - fab.fab$l_fna = src; - fab.fab$b_fns = slen + 1; - fab.fab$l_nam = &nam; - fab.fab$l_fop = FAB$M_NAM; - - nam.nam$l_esa = esa; - nam.nam$b_ess = sizeof esa; - nam.nam$b_nop |= NAM$M_SYNCHK; - - /* We call SYS$PARSE to handle such things as [--] for us. */ - if (SYS$PARSE(&fab, 0, 0) == RMS$_NORMAL) - { - slen = nam.nam$b_esl - 1; - if (esa[slen] == ';' && esa[slen - 1] == '.') - slen -= 2; - esa[slen + 1] = '\0'; - src = esa; - } - if (src[slen] != FN_C_AFTER_DIR && src[slen] != FN_C_AFTER_DIR_2) - { - /* what about when we have logical_name:???? */ - if (src[slen] == FN_DEVCHAR) - { /* Xlate logical name and see what we get */ - (void) strmov(dst,src); - dst[slen] = 0; /* remove colon */ - if (!(src = getenv (dst))) - return dst; /* Can't translate */ - - /* should we jump to the beginning of this procedure? - Good points: allows us to use logical names that xlate - to Unix names, - Bad points: can be a problem if we just translated to a device - name... - For now, I'll punt and always expect VMS names, and hope for - the best! */ - - slen = strlen (src) - 1; - if (src[slen] != FN_C_AFTER_DIR && src[slen] != FN_C_AFTER_DIR_2) - { /* no recursion here! */ - (void) strmov(dst, src); - return(dst); - } - } - else - { /* not a directory spec */ - (void) strmov(dst, src); - return(dst); - } - } - - bracket = src[slen]; /* End char */ - if (!(ptr = strchr (src, bracket - 2))) - { /* no opening bracket */ - (void) strmov (dst, src); - return dst; - } - if (!(rptr = strrchr (src, '.'))) - rptr = ptr; - slen = rptr - src; - (void) strmake (dst, src, slen); - - if (*rptr == '.') - { /* Put bracket and add */ - dst[slen++] = bracket; /* (rptr+1) after this */ - } - else - { - /* If we have the top-level of a rooted directory (i.e. xx:[000000]), - then translate the device and recurse. */ - - if (dst[slen - 1] == ':' - && dst[slen - 2] != ':' /* skip decnet nodes */ - && strcmp(src + slen, "[000000]") == 0) - { - dst[slen - 1] = '\0'; - if ((ptr = getenv (dst)) - && (rlen = strlen (ptr) - 1) > 0 - && (ptr[rlen] == FN_C_AFTER_DIR || ptr[rlen] == FN_C_AFTER_DIR_2) - && ptr[rlen - 1] == '.') - { - (void) strmov(esa,ptr); - esa[rlen - 1] = FN_C_AFTER_DIR; - esa[rlen] = '\0'; - return (directory_file_name (dst, esa)); - } - else - dst[slen - 1] = ':'; - } - (void) strmov(dst+slen,"[000000]"); - slen += 8; - } - (void) strmov(strmov(dst+slen,rptr+1)-1,".DIR.1"); - return dst; - } - (void) strmov(dst, src); - if (dst[slen] == '/' && slen > 1) - dst[slen] = 0; - return dst; -#endif /* VMS */ -} /* directory_file_name */ +} #else @@ -400,7 +270,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((uchar*) buffer,MYF(0)); + my_free(buffer); goto error; } init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE); @@ -547,7 +417,7 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags) DBUG_PRINT("error",("Got errno: %d from stat", errno)); my_errno= errno; if (m_used) /* Free if new area */ - my_free((uchar*) stat_area,MYF(0)); + my_free(stat_area); error: if (my_flags & (MY_FAE+MY_WME)) diff --git a/mysys/my_lock.c b/mysys/my_lock.c index 1436c845286..49c94ea838c 100644 --- a/mysys/my_lock.c +++ b/mysys/my_lock.c @@ -22,9 +22,6 @@ #undef NO_ALARM_LOOP #endif #include <my_alarm.h> -#ifdef __NETWARE__ -#include <nks/fsio.h> -#endif #ifdef _WIN32 #define WIN_LOCK_INFINITE -1 @@ -145,60 +142,14 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length, int value; ALARM_VARIABLES; #endif -#ifdef __NETWARE__ - int nxErrno; -#endif DBUG_ENTER("my_lock"); DBUG_PRINT("my",("fd: %d Op: %d start: %ld Length: %ld MyFlags: %d", fd,locktype,(long) start,(long) length,MyFlags)); -#ifdef VMS - DBUG_RETURN(0); -#else if (my_disable_locking) DBUG_RETURN(0); -#if defined(__NETWARE__) - { - NXSOffset_t nxLength = length; - unsigned long nxLockFlags = 0; - - if (length == F_TO_EOF) - { - /* EOF is interpreted as a very large length. */ - nxLength = 0x7FFFFFFFFFFFFFFF; - } - - if (locktype == F_UNLCK) - { - /* The lock flags are currently ignored by NKS. */ - if (!(nxErrno= NXFileRangeUnlock(fd, 0L, start, nxLength))) - DBUG_RETURN(0); - } - else - { - if (locktype == F_RDLCK) - { - /* A read lock is mapped to a shared lock. */ - nxLockFlags = NX_RANGE_LOCK_SHARED; - } - else - { - /* A write lock is mapped to an exclusive lock. */ - nxLockFlags = NX_RANGE_LOCK_EXCL; - } - - if (MyFlags & MY_DONT_WAIT) - { - /* Don't block on the lock. */ - nxLockFlags |= NX_RANGE_LOCK_TRYLOCK; - } - - if (!(nxErrno= NXFileRangeLock(fd, nxLockFlags, start, nxLength))) - DBUG_RETURN(0); - } - } -#elif defined(_WIN32) +#if defined(_WIN32) { int timeout_sec; if (MyFlags & MY_DONT_WAIT) @@ -257,12 +208,9 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length, #endif /* HAVE_FCNTL */ #endif /* HAVE_LOCKING */ -#ifdef __NETWARE__ - my_errno = nxErrno; -#else - /* We got an error. We don't want EACCES errors */ + /* We got an error. We don't want EACCES errors */ my_errno=(errno == EACCES) ? EAGAIN : errno ? errno : -1; -#endif + if (MyFlags & MY_WME) { if (locktype == F_UNLCK) @@ -272,5 +220,4 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length, } DBUG_PRINT("error",("my_errno: %d (%d)",my_errno,errno)); DBUG_RETURN(-1); -#endif /* ! VMS */ } /* my_lock */ diff --git a/mysys/my_lockmem.c b/mysys/my_lockmem.c index 1b582783d33..a37db6b2089 100644 --- a/mysys/my_lockmem.c +++ b/mysys/my_lockmem.c @@ -74,7 +74,7 @@ uchar *my_malloc_lock(uint size,myf MyFlags) } -void my_free_lock(uchar *ptr,myf Myflags __attribute__((unused))) +void my_free_lock(uchar *ptr) { LIST *list; struct st_mem_list *element=0; @@ -91,8 +91,7 @@ void my_free_lock(uchar *ptr,myf Myflags __attribute__((unused))) } } mysql_mutex_unlock(&THR_LOCK_malloc); - if (element) - my_free((uchar*) element,MYF(0)); + my_free(element); free(ptr); /* Free even if not locked */ } diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c index 13d2375eb99..fc2dc98c3c5 100644 --- a/mysys/my_malloc.c +++ b/mysys/my_malloc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -11,28 +11,31 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifdef SAFEMALLOC /* We don't need SAFEMALLOC here */ -#undef SAFEMALLOC -#endif + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "mysys_priv.h" #include "mysys_err.h" #include <m_string.h> - /* My memory allocator */ +/** + Allocate a sized block of memory. + @param size The size of the memory block in bytes. + @param flags Failure action modifiers (bitmasks). + + @return A pointer to the allocated memory block, or NULL on failure. +*/ void *my_malloc(size_t size, myf my_flags) { void* point; DBUG_ENTER("my_malloc"); DBUG_PRINT("my",("size: %lu my_flags: %d", (ulong) size, my_flags)); + /* Safety */ if (!size) - size=1; /* Safety */ + size=1; - point= (char *) malloc(size); + point= malloc(size); DBUG_EXECUTE_IF("simulate_out_of_memory", { free(point); @@ -52,33 +55,87 @@ void *my_malloc(size_t size, myf my_flags) exit(1); } else if (my_flags & MY_ZEROFILL) - bzero(point,size); - DBUG_PRINT("exit",("ptr: 0x%lx", (long) point)); - DBUG_RETURN((void*) point); -} /* my_malloc */ + bzero(point, size); + DBUG_PRINT("exit",("ptr: %p", point)); + DBUG_RETURN(point); +} + + +/** + @brief wrapper around realloc() + + @param oldpoint pointer to currently allocated area + @param size new size requested, must be >0 + @param my_flags flags + + @note if size==0 realloc() may return NULL; my_realloc() treats this as an + error which is not the intention of realloc() +*/ +void *my_realloc(void *oldpoint, size_t size, myf my_flags) +{ + void *point; + DBUG_ENTER("my_realloc"); + DBUG_PRINT("my",("ptr: %p size: %lu my_flags: %d", oldpoint, + (ulong) size, my_flags)); + + DBUG_ASSERT(size > 0); + if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR)) + DBUG_RETURN(my_malloc(size, my_flags)); +#ifdef USE_HALLOC + if (!(point = malloc(size))) + { + if (my_flags & MY_FREE_ON_ERROR) + my_free(oldpoint); + if (my_flags & MY_HOLD_ON_ERROR) + DBUG_RETURN(oldpoint); + my_errno=errno; + if (my_flags & MY_FAE+MY_WME) + my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size); + } + else + { + memcpy(point,oldpoint,size); + free(oldpoint); + } +#else + if ((point= realloc(oldpoint, size)) == NULL) + { + if (my_flags & MY_FREE_ON_ERROR) + my_free(oldpoint); + if (my_flags & MY_HOLD_ON_ERROR) + DBUG_RETURN(oldpoint); + my_errno=errno; + if (my_flags & (MY_FAE+MY_WME)) + my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), size); + } +#endif + DBUG_PRINT("exit",("ptr: %p", point)); + DBUG_RETURN(point); +} - /* Free memory allocated with my_malloc */ - /*ARGSUSED*/ +/** + Free memory allocated with my_malloc. -void my_no_flags_free(void* ptr) + @remark Relies on free being able to handle a NULL argument. + + @param ptr Pointer to the memory allocated by my_malloc. +*/ +void my_free(void *ptr) { DBUG_ENTER("my_free"); - DBUG_PRINT("my",("ptr: 0x%lx", (long) ptr)); - if (ptr) - free(ptr); + DBUG_PRINT("my",("ptr: %p", ptr)); + free(ptr); DBUG_VOID_RETURN; -} /* my_free */ - +} - /* malloc and copy */ -void* my_memdup(const void *from, size_t length, myf my_flags) +void *my_memdup(const void *from, size_t length, myf my_flags) { void *ptr; if ((ptr= my_malloc(length,my_flags)) != 0) memcpy(ptr, from, length); - return(ptr); + return ptr; } @@ -87,18 +144,19 @@ char *my_strdup(const char *from, myf my_flags) 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); + memcpy(ptr, from, length); + return ptr; } char *my_strndup(const char *from, size_t length, myf my_flags) { char *ptr; - if ((ptr= (char*) my_malloc(length+1,my_flags)) != 0) + if ((ptr= (char*) my_malloc(length+1, my_flags))) { - memcpy((uchar*) ptr, (uchar*) from, length); - ptr[length]=0; + memcpy(ptr, from, length); + ptr[length]= 0; } - return((char*) ptr); + return ptr; } + diff --git a/mysys/my_mess.c b/mysys/my_mess.c index 0ec97525ae8..513afe39054 100644 --- a/mysys/my_mess.c +++ b/mysys/my_mess.c @@ -22,11 +22,7 @@ void my_message_stderr(uint error __attribute__((unused)), DBUG_PRINT("enter",("message: %s",str)); (void) fflush(stdout); if (MyFlags & ME_BELL) -#ifdef __NETWARE__ - ringbell(); /* Bell */ -#else - (void) fputc('\007',stderr); /* Bell */ -#endif /* __NETWARE__ */ + (void) fputc('\007', stderr); if (my_progname) { (void)fputs(my_progname,stderr); (void)fputs(": ",stderr); diff --git a/mysys/my_mmap.c b/mysys/my_mmap.c index 303d8efaf30..82ee1562bc2 100644 --- a/mysys/my_mmap.c +++ b/mysys/my_mmap.c @@ -38,13 +38,16 @@ void *my_mmap(void *addr, size_t len, int prot, HANDLE hFileMap; LPVOID ptr; HANDLE hFile= (HANDLE)my_get_osfhandle(fd); + DBUG_ENTER("my_mmap"); + DBUG_PRINT("mysys", ("map fd: %d", fd)); + if (hFile == INVALID_HANDLE_VALUE) - return MAP_FAILED; + DBUG_RETURN(MAP_FAILED); hFileMap=CreateFileMapping(hFile, &mmap_security_attributes, PAGE_READWRITE, 0, (DWORD) len, NULL); if (hFileMap == 0) - return MAP_FAILED; + DBUG_RETURN(MAP_FAILED); ptr=MapViewOfFile(hFileMap, prot & PROT_WRITE ? FILE_MAP_WRITE : FILE_MAP_READ, @@ -59,14 +62,19 @@ void *my_mmap(void *addr, size_t len, int prot, CloseHandle(hFileMap); if (ptr) - return ptr; + { + DBUG_PRINT("mysys", ("mapped addr: %p", ptr)); + DBUG_RETURN(ptr); + } - return MAP_FAILED; + DBUG_RETURN(MAP_FAILED); } int my_munmap(void *addr, size_t len) { - return UnmapViewOfFile(addr) ? 0 : -1; + DBUG_ENTER("my_munmap"); + DBUG_PRINT("mysys", ("unmap addr: %p", addr)); + DBUG_RETURN(UnmapViewOfFile(addr) ? 0 : -1); } int my_msync(int fd, void *addr, size_t len, int flags) diff --git a/mysys/my_netware.c b/mysys/my_netware.c deleted file mode 100644 index 5b5c39c0ac0..00000000000 --- a/mysys/my_netware.c +++ /dev/null @@ -1,150 +0,0 @@ -/* Copyright (C) 2003 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* - Functions specific to netware -*/ - -#include <mysys_priv.h> -#ifdef __NETWARE__ - #include <string.h> - #include <library.h> - -/* - PMUserLicenseRequest is an API exported by the polimgr.nlm - (loaded by the NetWare OS when it comes up) for use by other - NLM-based NetWare products/services. - PMUserLicenseRequest provides a couple of functions: - 1) it will optionally request a User license or ensure that - one already exists for the specified User in userInfo - 2) it utilizes the NetWare usage metering service to - record usage information about your product/service. -*/ - -long PMMeteredUsageRequest -( - /* - NDS distinguished name or IP address or ??. asciiz string, e.g. - ".CN=Admin.O=this.T=MYTREE." - */ - char *userInfo, - long infoType, /* see defined values */ - /* - string used to identify the calling service, used to index the - metered info e.g. "iPrint" - */ - char *serviceID, - char tranAddrType, /* type of address that follows */ - char *tranAddr, /* ptr to a 10-byte array */ - long flags, /* see defined values */ - /* NLS error code, if any. NULL input is okay */ - long *licRequestErrCode, - /* meter service error code, if any. NULL input is okay */ - long *storeMeterInfoErrCode, - /* - error code from NLSMeter if - storeMeterInfoErrCode == PM_LICREQ_NLSMETERERROR. - NULL input is okay - */ - long *NLSMeterErrCode -); - -typedef long(*PMUR)(const char*, long, const char*, char, - const char*, long, long*, long*, long*); - -/* infoType */ -/* indicates that the info in the userInfo param is an NDS user */ -#define PM_USERINFO_TYPE_NDS 1 -/* indicates that the info in the userInfo param is NOT an NDS user */ -#define PM_USERINFO_TYPE_ADDRESS 2 - -/* Flags */ - -/* - Tells the service that it should not check to see if the NDS user - contained in the userInfo param has a NetWare User License - just - record metering information; this is ignored if infoType != - PM_USERINFO_TYPE_NDS -*/ - -#define PM_FLAGS_METER_ONLY 0x0000001 - -/* - Indicates that the values in the userInfo and serviceID parameters - are unicode strings, so that the metering service bypasses - converting these to unicode (again) -*/ -#define PM_LICREQ_ALREADY_UNICODE 0x0000002 -/* - Useful only if infoType is PM_USERINFO_TYPE_NDS - indicates a "no - stop" policy of the calling service -*/ -#define PM_LICREQ_ALWAYS_METER 0x0000004 - - -/* - net Address Types - system-defined types of net addresses that can - be used in the tranAddrType field -*/ - -#define NLS_TRAN_TYPE_IPX 0x00000001 /* An IPX address */ -#define NLS_TRAN_TYPE_IP 0x00000008 /* An IP address */ -#define NLS_ADDR_TYPE_MAC 0x000000F1 /* a MAC address */ - -/* - Net Address Sizes - lengths that correspond to the tranAddrType - field (just fyi) -*/ -#define NLS_IPX_ADDR_SIZE 10 /* the size of an IPX address */ -#define NLS_IP_ADDR_SIZE 4 /* the size of an IP address */ -#define NLS_MAC_ADDR_SIZE 6 /* the size of a MAC address */ - - -void netware_reg_user(const char *ip, const char *user, - const char *application) -{ - PMUR usage_request; - long licRequestErrCode = 0; - long storeMeterInfoErrCode = 0; - long nlsMeterErrCode = 0; - - /* import the symbol */ - usage_request= ((PMUR)ImportPublicObject(getnlmhandle(), - "PMMeteredUsageRequest")); - if (usage_request != NULL) - { - unsigned long iaddr; - char addr[NLS_IPX_ADDR_SIZE]; - - /* create address */ - iaddr = htonl(inet_addr(ip)); - bzero(addr, NLS_IPX_ADDR_SIZE); - memcpy(addr, &iaddr, NLS_IP_ADDR_SIZE); - - /* call to NLS */ - usage_request(user, - PM_USERINFO_TYPE_ADDRESS, - application, - NLS_TRAN_TYPE_IP, - addr, - PM_FLAGS_METER_ONLY, - &licRequestErrCode, - &storeMeterInfoErrCode, - &nlsMeterErrCode); - /* release symbol */ - UnImportPublicObject(getnlmhandle(), "PMMeteredUsageRequest"); - } -} -#endif /* __NETWARE__ */ diff --git a/mysys/my_once.c b/mysys/my_once.c index 727b8477365..32d07802028 100644 --- a/mysys/my_once.c +++ b/mysys/my_once.c @@ -15,10 +15,6 @@ /* Not MT-SAFE */ -#ifdef SAFEMALLOC /* We don't need SAFEMALLOC here */ -#undef SAFEMALLOC -#endif - #include "mysys_priv.h" #include "my_static.h" #include "mysys_err.h" diff --git a/mysys/my_open.c b/mysys/my_open.c index a50baf2c417..8f34ce1c6dc 100644 --- a/mysys/my_open.c +++ b/mysys/my_open.c @@ -88,7 +88,7 @@ int my_close(File fd, myf MyFlags) } if ((uint) fd < my_file_limit && my_file_info[fd].type != UNOPEN) { - my_free(my_file_info[fd].name, MYF(0)); + my_free(my_file_info[fd].name); #if defined(THREAD) && !defined(HAVE_PREAD) && !defined(_WIN32) mysql_mutex_destroy(&my_file_info[fd].mutex); #endif diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c index 3019e4bc5c1..270d13928e3 100644 --- a/mysys/my_pthread.c +++ b/mysys/my_pthread.c @@ -45,34 +45,6 @@ void *my_pthread_getspecific_imp(pthread_key_t key) } #endif -#ifdef __NETWARE__ -/* - Don't kill the LibC Reaper thread or the main thread -*/ -#include <nks/thread.h> -#undef pthread_exit -void my_pthread_exit(void *status) -{ - NXThreadId_t tid; - NXContext_t ctx; - char name[NX_MAX_OBJECT_NAME_LEN+1] = ""; - - tid= NXThreadGetId(); - if (tid == NX_INVALID_THREAD_ID || !tid) - return; - if (NXThreadGetContext(tid, &ctx) || - NXContextGetName(ctx, name, sizeof(name)-1)) - return; - - /* - "MYSQLD.NLM's LibC Reaper" or "MYSQLD.NLM's main thread" - with a debug build of LibC the reaper can have different names - */ - if (!strindex(name, "\'s")) - pthread_exit(status); -} -#endif - /* Some functions for RTS threads, AIX, Siemens Unix and UnixWare 7 (and DEC OSF/1 3.2 too) diff --git a/mysys/my_rdtsc.c b/mysys/my_rdtsc.c index 073663e3d96..c8ef38efbdc 100644 --- a/mysys/my_rdtsc.c +++ b/mysys/my_rdtsc.c @@ -86,10 +86,6 @@ #include <sys/times.h> /* for times */ #endif -#if defined(__NETWARE__) -#include <nks/time.h> /* for NXGetTime */ -#endif - #if defined(__INTEL_COMPILER) && defined(__ia64__) && defined(HAVE_IA64INTRIN_H) #include <ia64intrin.h> /* for __GetReg */ #endif @@ -265,12 +261,6 @@ ulonglong my_timer_nanoseconds(void) clock_gettime(CLOCK_REALTIME, &tp); return (ulonglong) tp.tv_sec * 1000000000 + (ulonglong) tp.tv_nsec; } -#elif defined(__NETWARE__) - { - NXTime_t tm; - NXGetTime(NX_SINCE_1970, NX_NSECONDS, &tm); - return (ulonglong) tm; - } #elif defined(__APPLE__) && defined(__MACH__) { ulonglong tm; @@ -322,12 +312,6 @@ ulonglong my_timer_microseconds(void) QueryPerformanceCounter(&t_cnt); return (ulonglong) t_cnt.QuadPart; } -#elif defined(__NETWARE__) - { - NXTime_t tm; - NXGetTime(NX_SINCE_1970, NX_USECONDS, &tm); - return (ulonglong) tm; - } #else return 0; #endif @@ -354,12 +338,6 @@ ulonglong my_timer_milliseconds(void) GetSystemTimeAsFileTime( &ft ); return ((ulonglong)ft.dwLowDateTime + (((ulonglong)ft.dwHighDateTime) << 32))/10000; -#elif defined(__NETWARE__) - { - NXTime_t tm; - NXGetTime(NX_SINCE_1970, NX_MSECONDS, &tm); - return (ulonglong)tm; - } #else return 0; #endif @@ -378,12 +356,6 @@ ulonglong my_timer_ticks(void) struct tms times_buf; return (ulonglong) times(×_buf); } -#elif defined(__NETWARE__) - { - NXTime_t tm; - NXGetTime(NX_SINCE_BOOT, NX_TICKS, &tm); - return (ulonglong) tm; - } #elif defined(_WIN32) return (ulonglong) GetTickCount(); #else @@ -583,8 +555,6 @@ void my_timer_init(MY_TIMER_INFO *mti) mti->nanoseconds.routine= MY_TIMER_ROUTINE_GETHRTIME; #elif defined(HAVE_CLOCK_GETTIME) mti->nanoseconds.routine= MY_TIMER_ROUTINE_CLOCK_GETTIME; -#elif defined(__NETWARE__) - mti->nanoseconds.routine= MY_TIMER_ROUTINE_NXGETTIME; #elif defined(__APPLE__) && defined(__MACH__) mti->nanoseconds.routine= MY_TIMER_ROUTINE_MACH_ABSOLUTE_TIME; #else @@ -614,8 +584,6 @@ void my_timer_init(MY_TIMER_INFO *mti) mti->microseconds.routine= MY_TIMER_ROUTINE_QUERYPERFORMANCECOUNTER; } } -#elif defined(__NETWARE__) - mti->microseconds.routine= MY_TIMER_ROUTINE_NXGETTIME; #else mti->microseconds.routine= 0; #endif @@ -633,8 +601,6 @@ void my_timer_init(MY_TIMER_INFO *mti) mti->milliseconds.routine= MY_TIMER_ROUTINE_FTIME; #elif defined(_WIN32) mti->milliseconds.routine= MY_TIMER_ROUTINE_GETSYSTEMTIMEASFILETIME; -#elif defined(__NETWARE__) - mti->milliseconds.routine= MY_TIMER_ROUTINE_NXGETTIME; #elif defined(HAVE_TIME) mti->milliseconds.routine= MY_TIMER_ROUTINE_TIME; #else @@ -652,8 +618,6 @@ void my_timer_init(MY_TIMER_INFO *mti) mti->ticks.frequency= 100; /* permanent assumption */ #if defined(HAVE_SYS_TIMES_H) && defined(HAVE_TIMES) mti->ticks.routine= MY_TIMER_ROUTINE_TIMES; -#elif defined(__NETWARE__) - mti->ticks.routine= MY_TIMER_ROUTINE_NXGETTIME; #elif defined(_WIN32) mti->ticks.routine= MY_TIMER_ROUTINE_GETTICKCOUNT; #else @@ -998,7 +962,7 @@ void my_timer_init(MY_TIMER_INFO *mti) We tested with AIX, Solaris (x86 + Sparc), Linux (x86 + Itanium), Windows, 64-bit Windows, QNX, FreeBSD, HPUX, - Irix, Mac. We didn't test with NetWare or SCO. + Irix, Mac. We didn't test with SCO. */ diff --git a/mysys/my_realloc.c b/mysys/my_realloc.c deleted file mode 100644 index a55282e03a0..00000000000 --- a/mysys/my_realloc.c +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (C) 2000 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifdef SAFEMALLOC /* We don't need SAFEMALLOC here */ -#undef SAFEMALLOC -#endif - -#include "mysys_priv.h" -#include "mysys_err.h" - - /* My memory re allocator */ - -/** - @brief wrapper around realloc() - - @param oldpoint pointer to currently allocated area - @param size new size requested, must be >0 - @param my_flags flags - - @note if size==0 realloc() may return NULL; my_realloc() treats this as an - error which is not the intention of realloc() -*/ -void* my_realloc(void* oldpoint, size_t size, myf my_flags) -{ - void *point; - DBUG_ENTER("my_realloc"); - DBUG_PRINT("my",("ptr: 0x%lx size: %lu my_flags: %d", (long) oldpoint, - (ulong) size, my_flags)); - - DBUG_ASSERT(size > 0); - if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR)) - DBUG_RETURN(my_malloc(size,my_flags)); -#ifdef USE_HALLOC - if (!(point = malloc(size))) - { - if (my_flags & MY_FREE_ON_ERROR) - my_free(oldpoint,my_flags); - if (my_flags & MY_HOLD_ON_ERROR) - DBUG_RETURN(oldpoint); - my_errno=errno; - if (my_flags & MY_FAE+MY_WME) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size); - } - else - { - memcpy(point,oldpoint,size); - free(oldpoint); - } -#else - if ((point= (uchar*) realloc(oldpoint,size)) == NULL) - { - if (my_flags & MY_FREE_ON_ERROR) - my_free(oldpoint, my_flags); - if (my_flags & MY_HOLD_ON_ERROR) - DBUG_RETURN(oldpoint); - my_errno=errno; - if (my_flags & (MY_FAE+MY_WME)) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), size); - } -#endif - DBUG_PRINT("exit",("ptr: 0x%lx", (long) point)); - DBUG_RETURN(point); -} /* my_realloc */ diff --git a/mysys/my_redel.c b/mysys/my_redel.c index 77040870048..300bac6e296 100644 --- a/mysys/my_redel.c +++ b/mysys/my_redel.c @@ -76,7 +76,7 @@ end: int my_copystat(const char *from, const char *to, int MyFlags) { struct stat statbuf; -#if !defined(__WIN__) && !defined(__NETWARE__) +#if !defined(__WIN__) int res; #endif @@ -91,17 +91,15 @@ int my_copystat(const char *from, const char *to, int MyFlags) return 1; (void) chmod(to, statbuf.st_mode & 07777); /* Copy modes */ -#if !defined(__WIN__) && !defined(__NETWARE__) +#if !defined(__WIN__) if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING) { if (MyFlags & MY_LINK_WARNING) my_error(EE_LINK_WARNING,MYF(ME_BELL+ME_WAITTANG),from,statbuf.st_nlink); } res= chown(to, statbuf.st_uid, statbuf.st_gid); /* Copy ownership */ -#endif /* !__WIN__ && !__NETWARE__ */ +#endif /* !__WIN__ */ -#ifndef VMS -#ifndef __ZTC__ if (MyFlags & MY_COPYTIME) { struct utimbuf timep; @@ -109,15 +107,6 @@ int my_copystat(const char *from, const char *to, int MyFlags) timep.modtime = statbuf.st_mtime; (void) utime((char*) to, &timep);/* Update last accessed and modified times */ } -#else - if (MyFlags & MY_COPYTIME) - { - time_t time[2]; - time[0]= statbuf.st_atime; - time[1]= statbuf.st_mtime; - (void) utime((char*) to, time);/* Update last accessed and modified times */ - } -#endif -#endif + return 0; } /* my_copystat */ diff --git a/mysys/my_rename.c b/mysys/my_rename.c index 39e6056a9e4..1a4e7b2b409 100644 --- a/mysys/my_rename.c +++ b/mysys/my_rename.c @@ -44,7 +44,7 @@ int my_rename(const char *from, const char *to, myf MyFlags) } #endif #if defined(HAVE_RENAME) -#if defined(__WIN__) || defined(__NETWARE__) +#if defined(__WIN__) /* On windows we can't rename over an existing file: Remove any conflicting files: diff --git a/mysys/my_sleep.c b/mysys/my_sleep.c index 87170e4af41..6d1bdd5dc55 100644 --- a/mysys/my_sleep.c +++ b/mysys/my_sleep.c @@ -20,9 +20,7 @@ void my_sleep(ulong m_seconds) { -#ifdef __NETWARE__ - delay(m_seconds/1000+1); -#elif defined(__WIN__) +#if defined(__WIN__) Sleep(m_seconds/1000+1); /* Sleep() has millisecond arg */ #elif defined(HAVE_SELECT) struct timeval t; diff --git a/mysys/my_static.c b/mysys/my_static.c index ff5abba29d3..0b2f86b4038 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -27,20 +27,20 @@ my_bool timed_mutexes= 0; /* from my_init */ char * home_dir=0; const char *my_progname=0; -char NEAR curr_dir[FN_REFLEN]= {0}, - NEAR home_dir_buff[FN_REFLEN]= {0}; +char curr_dir[FN_REFLEN]= {0}, + home_dir_buff[FN_REFLEN]= {0}; ulong my_stream_opened=0,my_file_opened=0, my_tmp_file_created=0; ulong my_file_total_opened= 0; -int NEAR my_umask=0664, NEAR my_umask_dir=0777; +int my_umask=0664, my_umask_dir=0777; #ifndef THREAD -int NEAR my_errno=0; +int my_errno=0; #endif struct st_my_file_info my_file_info_default[MY_NFILE]; uint my_file_limit= MY_NFILE; struct st_my_file_info *my_file_info= my_file_info_default; /* From mf_brkhant */ -int NEAR my_dont_interrupt=0; +int my_dont_interrupt=0; volatile int _my_signals=0; struct st_remember _my_sig_remember[MAX_SIGNALS]={{0,0}}; #ifdef THREAD @@ -84,7 +84,7 @@ ulong my_time_to_wait_for_lock=2; /* In seconds */ /* from errors.c */ #ifdef SHARED_LIBRARY -char * NEAR globerrs[GLOBERRS]; /* my_error_messages is here */ +const char *globerrs[GLOBERRS]; /* my_error_messages is here */ #endif void (*my_abort_hook)(int) = (void(*)(int)) exit; void (*error_handler_hook)(uint error, const char *str, myf MyFlags)= @@ -119,10 +119,10 @@ ulonglong query_performance_frequency, query_performance_offset; #endif /* How to disable options */ -my_bool NEAR my_disable_locking=0; -my_bool NEAR my_disable_async_io=0; -my_bool NEAR my_disable_flush_key_blocks=0; -my_bool NEAR my_disable_symlinks=0; +my_bool my_disable_locking=0; +my_bool my_disable_async_io=0; +my_bool my_disable_flush_key_blocks=0; +my_bool my_disable_symlinks=0; /* Note that PSI_hook and PSI_server are unconditionally diff --git a/mysys/my_static.h b/mysys/my_static.h index c336115bc35..f50f7d8be10 100644 --- a/mysys/my_static.h +++ b/mysys/my_static.h @@ -53,7 +53,7 @@ struct st_irem }; -extern char NEAR curr_dir[FN_REFLEN],NEAR home_dir_buff[FN_REFLEN]; +extern char curr_dir[FN_REFLEN], home_dir_buff[FN_REFLEN]; extern volatile int _my_signals; extern struct st_remember _my_sig_remember[MAX_SIGNALS]; diff --git a/mysys/my_windac.c b/mysys/my_windac.c index f846853f7be..0c924188623 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((uchar*) sa, MYF(MY_ALLOW_ZERO_PTR)); - my_free((uchar*) dacl, MYF(MY_ALLOW_ZERO_PTR)); + my_free(sa); + my_free(dacl); *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((uchar*) attr->dacl, MYF(0)); - my_free((uchar*) sa, MYF(0)); + my_free(attr->dacl); + my_free(sa); } } diff --git a/mysys/queues.c b/mysys/queues.c index 9c85e493141..25a310c0752 100644 --- a/mysys/queues.c +++ b/mysys/queues.c @@ -194,11 +194,8 @@ int resize_queue(QUEUE *queue, uint max_elements) void delete_queue(QUEUE *queue) { DBUG_ENTER("delete_queue"); - if (queue->root) - { - my_free((uchar*) queue->root,MYF(0)); - queue->root=0; - } + my_free(queue->root); + queue->root= NULL; DBUG_VOID_RETURN; } diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c deleted file mode 100644 index 8407657efb7..00000000000 --- a/mysys/safemalloc.c +++ /dev/null @@ -1,576 +0,0 @@ -/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* - * Memory sub-system, written by Bjorn Benson - Fixed to use my_sys scheme by Michael Widenius - - [This posting refers to an article entitled "oops, corrupted memory - again!" in net.lang.c. I am posting it here because it is source.] - - My tool for approaching this problem is to build another level of data - abstraction on top of malloc() and free() that implements some checking. - This does a number of things for you: - - Checks for overruns and underruns on allocated data - - Keeps track of where in the program the memory was malloc'ed - - Reports on pieces of memory that were not free'ed - - Records some statistics such as maximum memory used - - Marks newly malloc'ed and newly free'ed memory with special values - You can use this scheme to: - - Find bugs such as overrun, underrun, etc because you know where - a piece of data was malloc'ed and where it was free'ed - - Find bugs where memory was not free'ed - - Find bugs where newly malloc'ed memory is used without initializing - - Find bugs where newly free'ed memory is still used - - Determine how much memory your program really uses - - and other things - - To implement my scheme you must have a C compiler that has __LINE__ and - __FILE__ macros. If your compiler doesn't have these then (a) buy another: - compilers that do are available on UNIX 4.2bsd based systems and the PC, - and probably on other machines; or (b) change my scheme somehow. I have - recomendations on both these points if you would like them (e-mail please). - - There are 4 functions in my package: - char *NEW( uSize ) Allocate memory of uSize bytes - (equivalent to malloc()) - char *REA( pPtr, uSize) Allocate memory of uSize bytes, move data and - free pPtr. - (equivalent to realloc()) - FREE( pPtr ) Free memory allocated by NEW - (equivalent to free()) - TERMINATE(file,flag) End system, report errors and stats on file - I personally use two more functions, but have not included them here: - char *STRSAVE( sPtr ) Save a copy of the string in dynamic memory - char *RENEW( pPtr, uSize ) - (equivalent to realloc()) - -*/ - -#ifndef SAFEMALLOC -#define SAFEMALLOC /* Get protos from my_sys */ -#endif - -#include "mysys_priv.h" -#include <m_string.h> -#include "my_static.h" -#include "mysys_err.h" - -ulonglong sf_malloc_mem_limit= ~(ulonglong)0; - -#ifndef PEDANTIC_SAFEMALLOC -/* - Set to 1 after TERMINATE() if we had to fiddle with sf_malloc_count and - the linked list of blocks so that _sanity() will not fuss when it - is not supposed to -*/ -static int sf_malloc_tampered= 0; -#endif - - - /* Static functions prototypes */ - -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); - -/* - Note: We only fill up the allocated block. This do not include - malloc() roundoff or the extra space required by the irem - structures. -*/ - -/* - NEW'ed memory is filled with this value so that references to it will - end up being very strange. -*/ -#define ALLOC_VAL (uchar) 0xA5 -/* - FEEE'ed memory is filled with this value so that references to it will - end up being very strange. -*/ -#define FREE_VAL (uchar) 0x8F -#define MAGICKEY 0x14235296 /* A magic value for underrun key */ - -/* - Warning: do not change the MAGICEND? values to something with the - high bit set. Various C compilers (like the 4.2bsd one) do not do - the sign extension right later on in this code and you will get - erroneous errors. -*/ - -#define MAGICEND0 0x68 /* Magic values for overrun keys */ -#define MAGICEND1 0x34 /* " */ -#define MAGICEND2 0x7A /* " */ -#define MAGICEND3 0x15 /* " */ - - -/* Allocate some memory. */ - -void *_mymalloc(size_t size, const char *filename, uint lineno, myf MyFlags) -{ - struct st_irem *irem; - uchar *data; - DBUG_ENTER("_mymalloc"); - DBUG_PRINT("enter",("Size: %lu", (ulong) size)); - - if (!sf_malloc_quick) - (void) _sanity (filename, lineno); - - if (size + sf_malloc_cur_memory > sf_malloc_mem_limit) - irem= 0; - else - { - /* Allocate the physical memory */ - irem= (struct st_irem *) malloc (ALIGN_SIZE(sizeof(struct st_irem)) + - sf_malloc_prehunc + - size + /* size requested */ - 4 + /* overrun mark */ - sf_malloc_endhunc); - DBUG_EXECUTE_IF("simulate_out_of_memory", - { - free(irem); - irem= NULL; - }); - } - /* Check if there isn't anymore memory avaiable */ - if (!irem) - { - if (MyFlags & MY_FAE) - error_handler_hook=fatal_error_handler_hook; - if (MyFlags & (MY_FAE+MY_WME)) - { - char buff[256]; - 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 %lu byte (%luk), memory in use: %lu bytes (%luk)", - (ulong) size, (ulong) (size + 1023L) / 1024L, - (ulong) sf_malloc_max_memory, - (ulong) (sf_malloc_max_memory + 1023L) / 1024L); - my_message(EE_OUTOFMEMORY, buff, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH)); - } - DBUG_PRINT("error",("Out of memory, in use: %ld at line %d, '%s'", - (long) sf_malloc_max_memory, lineno, filename)); - DBUG_EXECUTE_IF("simulate_out_of_memory", - DBUG_SET("-d,simulate_out_of_memory");); - if (MyFlags & MY_FAE) - exit(1); - DBUG_RETURN ((void*) 0); - } - - /* Fill up the structure */ - 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= (char *) filename; - irem->linenum= lineno; - irem->datasize= size; - irem->prev= NULL; - - /* Add this remember structure to the linked list */ - mysql_mutex_lock(&THR_LOCK_malloc); - if ((irem->next= sf_malloc_root)) - sf_malloc_root->prev= irem; - sf_malloc_root= irem; - - /* Keep the statistics */ - sf_malloc_cur_memory+= size; - if (sf_malloc_cur_memory > sf_malloc_max_memory) - sf_malloc_max_memory= sf_malloc_cur_memory; - sf_malloc_count++; - mysql_mutex_unlock(&THR_LOCK_malloc); - - MEM_CHECK_ADDRESSABLE(data, size); - /* Set the memory to the aribtrary wierd value */ - if ((MyFlags & MY_ZEROFILL) || !sf_malloc_quick) - bfill(data, size, (char) (MyFlags & MY_ZEROFILL ? 0 : ALLOC_VAL)); - if (!(MyFlags & MY_ZEROFILL)) - MEM_UNDEFINED(data, size); - /* Return a pointer to the real data */ - DBUG_PRINT("exit",("ptr: %p", data)); - if (sf_min_adress > data) - sf_min_adress= data; - if (sf_max_adress < data) - sf_max_adress= data; - DBUG_RETURN((void*) data); -} - - -/* - Allocate some new memory and move old memoryblock there. - Free then old memoryblock -*/ - -void *_myrealloc(register void *ptr, register size_t size, - const char *filename, uint lineno, myf MyFlags) -{ - struct st_irem *irem; - char *data; - DBUG_ENTER("_myrealloc"); - - if (!ptr && (MyFlags & MY_ALLOW_ZERO_PTR)) - DBUG_RETURN(_mymalloc(size, filename, lineno, MyFlags)); - - if (!sf_malloc_quick) - (void) _sanity (filename, lineno); - - 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); - if (*((uint32*) (((char*) ptr)- sizeof(uint32))) != MAGICKEY) - { - fprintf(stderr, "Error: Reallocating unallocated data at line %d, '%s'\n", - lineno, filename); - DBUG_PRINT("safe",("Reallocating unallocated data at line %d, '%s'", - lineno, filename)); - (void) fflush(stderr); - 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((uchar*) data, ptr, (size_t) size); /* Copy old data */ - _myfree(ptr, filename, lineno, 0); /* Free not needed area */ - } - else - { - if (MyFlags & MY_HOLD_ON_ERROR) - DBUG_RETURN(ptr); - if (MyFlags & MY_FREE_ON_ERROR) - _myfree(ptr, filename, lineno, 0); - } - DBUG_RETURN(data); -} /* _myrealloc */ - - -/* Deallocate some memory. */ - -void _myfree(void *ptr, const char *filename, uint lineno, myf myflags) -{ - struct st_irem *irem; - DBUG_ENTER("_myfree"); - DBUG_PRINT("enter",("ptr: %p", ptr)); - - if (!sf_malloc_quick) - (void) _sanity (filename, lineno); - - if ((!ptr && (myflags & MY_ALLOW_ZERO_PTR)) || - check_ptr("Freeing",(uchar*) ptr,filename,lineno)) - DBUG_VOID_RETURN; - - /* Calculate the address of the remember structure */ - irem= (struct st_irem *) ((char*) ptr- ALIGN_SIZE(sizeof(struct st_irem))- - sf_malloc_prehunc); - - /* - Check to make sure that we have a real remember structure. - Note: this test could fail for four reasons: - (1) The memory was already free'ed - (2) The memory was never new'ed - (3) There was an underrun - (4) A stray pointer hit this location - */ - - if (*((uint32*) ((char*) ptr- sizeof(uint32))) != MAGICKEY) - { - fprintf(stderr, "Error: Freeing unallocated data at line %d, '%s'\n", - lineno, filename); - DBUG_PRINT("safe",("Unallocated data at line %d, '%s'",lineno,filename)); - (void) fflush(stderr); - DBUG_VOID_RETURN; - } - - /* Remove this structure from the linked list */ - mysql_mutex_lock(&THR_LOCK_malloc); - if (irem->prev) - irem->prev->next= irem->next; - else - sf_malloc_root= irem->next; - - if (irem->next) - irem->next->prev= irem->prev; - /* Handle the statistics */ - sf_malloc_cur_memory-= irem->datasize; - sf_malloc_count--; - mysql_mutex_unlock(&THR_LOCK_malloc); - -#ifndef HAVE_purify - /* Mark this data as free'ed */ - if (!sf_malloc_quick) - bfill(ptr, irem->datasize, (pchar) FREE_VAL); -#endif - MEM_NOACCESS(ptr, irem->datasize); - *((uint32*) ((char*) ptr- sizeof(uint32)))= ~MAGICKEY; - MEM_NOACCESS((char*) ptr - sizeof(uint32), sizeof(uint32)); - /* Actually free the memory */ - free((char*) irem); - DBUG_VOID_RETURN; -} - - /* Check if we have a wrong pointer */ - -static int check_ptr(const char *where, uchar *ptr, const char *filename, - uint lineno) -{ - if (!ptr) - { - fprintf(stderr, "Error: %s NULL pointer at line %d, '%s'\n", - where,lineno, filename); - DBUG_PRINT("safe",("Null pointer at line %d '%s'", lineno, filename)); - (void) fflush(stderr); - return 1; - } -#ifndef _MSC_VER - if ((long) ptr & (ALIGN_SIZE(1)-1)) - { - fprintf(stderr, "Error: %s wrong aligned pointer at line %d, '%s'\n", - where,lineno, filename); - DBUG_PRINT("safe",("Wrong aligned pointer at line %d, '%s'", - lineno,filename)); - (void) fflush(stderr); - return 1; - } -#endif - if (ptr < sf_min_adress || ptr > sf_max_adress) - { - fprintf(stderr, "Error: %s pointer out of range at line %d, '%s'\n", - where,lineno, filename); - DBUG_PRINT("safe",("Pointer out of range at line %d '%s'", - lineno,filename)); - (void) fflush(stderr); - return 1; - } - return 0; -} - - -/* - Report on all the memory pieces that have not been free'ed - - SYNOPSIS - TERMINATE() - file Write output to this file - flag If <> 0, also write statistics - */ - -void TERMINATE(FILE *file, uint flag) -{ - struct st_irem *irem; - DBUG_ENTER("TERMINATE"); - mysql_mutex_lock(&THR_LOCK_malloc); - - /* - Report the difference between number of calls to - NEW and the number of calls to FREE. >0 means more - NEWs than FREEs. <0, etc. - */ - - if (sf_malloc_count) - { - if (file) - { - fprintf(file, "Warning: Not freed memory segments: %u\n", sf_malloc_count); - (void) fflush(file); - } - DBUG_PRINT("safe",("sf_malloc_count: %u", sf_malloc_count)); - } - - /* - Report on all the memory that was allocated with NEW - but not free'ed with FREE. - */ - - if ((irem= sf_malloc_root)) - { - if (file) - { - fprintf(file, "Warning: Memory that was not free'ed (%lu bytes):\n", - (ulong) sf_malloc_cur_memory); - (void) fflush(file); - } - DBUG_PRINT("safe",("Memory that was not free'ed (%lu bytes):", - (ulong) sf_malloc_cur_memory)); - while (irem) - { - char *data= (((char*) irem) + ALIGN_SIZE(sizeof(struct st_irem)) + - sf_malloc_prehunc); - if (file) - { - fprintf(file, - "\t%6lu bytes at %p, allocated at line %4u in '%s'", - (ulong) irem->datasize, data, irem->linenum, irem->filename); - fprintf(file, "\n"); - (void) fflush(file); - } - DBUG_PRINT("safe", - ("%6lu bytes at %p, allocated at line %4d in '%s'", - (ulong) irem->datasize, - data, irem->linenum, irem->filename)); - irem= irem->next; - } - } - /* Report the memory usage statistics */ - if (file && flag) - { - fprintf(file, "Maximum memory usage: %lu bytes (%luk)\n", - (ulong) sf_malloc_max_memory, - (ulong) (sf_malloc_max_memory + 1023L) / 1024L); - (void) fflush(file); - } - DBUG_PRINT("safe",("Maximum memory usage: %lu bytes (%luk)", - (ulong) sf_malloc_max_memory, - (ulong) (sf_malloc_max_memory + 1023L) /1024L)); - mysql_mutex_unlock(&THR_LOCK_malloc); - DBUG_VOID_RETURN; -} - - -/* - Report where a piece of memory was allocated - - This is usefull to call from withing a debugger -*/ - - -void sf_malloc_report_allocated(void *memory) -{ - struct st_irem *irem; - for (irem= sf_malloc_root ; irem ; irem=irem->next) - { - char *data= (((char*) irem) + ALIGN_SIZE(sizeof(struct st_irem)) + - sf_malloc_prehunc); - if (data <= (char*) memory && (char*) memory <= data + irem->datasize) - { - printf("%lu bytes at %p, allocated at line %u in '%s'\n", - (ulong) irem->datasize, data, irem->linenum, irem->filename); - break; - } - } -} - - /* Returns 0 if chunk is ok */ - -static int _checkchunk(register struct st_irem *irem, const char *filename, - uint lineno) -{ - int flag=0; - char *magicp, *data; - - data= (((char*) irem) + ALIGN_SIZE(sizeof(struct st_irem)) + - sf_malloc_prehunc); - /* Check for a possible underrun */ - if (*((uint32*) (data- sizeof(uint32))) != MAGICKEY) - { - fprintf(stderr, "Error: Memory allocated at %s:%d was underrun,", - irem->filename, irem->linenum); - fprintf(stderr, " discovered at %s:%d\n", filename, lineno); - (void) fflush(stderr); - DBUG_PRINT("safe",("Underrun at %p, allocated at %s:%d", - data, irem->filename, irem->linenum)); - flag=1; - } - - /* Check for a possible overrun */ - magicp= data + irem->datasize; - if (*magicp++ != MAGICEND0 || - *magicp++ != MAGICEND1 || - *magicp++ != MAGICEND2 || - *magicp++ != MAGICEND3) - { - fprintf(stderr, "Error: Memory allocated at %s:%d was overrun,", - irem->filename, irem->linenum); - fprintf(stderr, " discovered at '%s:%d'\n", filename, lineno); - (void) fflush(stderr); - DBUG_PRINT("safe",("Overrun at %p, allocated at %s:%d", - data, irem->filename, irem->linenum)); - flag=1; - } - return(flag); -} - - - /* Returns how many wrong chunks */ - -int _sanity(const char *filename, uint lineno) -{ - reg1 struct st_irem *irem; - reg2 int flag=0; - uint count=0; - - mysql_mutex_lock(&THR_LOCK_malloc); -#ifndef PEDANTIC_SAFEMALLOC - if (sf_malloc_tampered && (int) sf_malloc_count < 0) - sf_malloc_count=0; -#endif - count=sf_malloc_count; - for (irem= sf_malloc_root; irem != NULL && count-- ; irem= irem->next) - flag+= _checkchunk (irem, filename, lineno); - mysql_mutex_unlock(&THR_LOCK_malloc); - if (count || irem) - { - const char *format="Error: Safemalloc link list destroyed, discovered at '%s:%d'"; - fprintf(stderr, format, filename, lineno); fputc('\n',stderr); - fprintf(stderr, "root=%p,count=%d,irem=%p\n", sf_malloc_root,count,irem); - (void) fflush(stderr); - DBUG_PRINT("safe",(format, filename, lineno)); - flag=1; - } - return flag; -} /* _sanity */ - - - /* malloc and copy */ - -void *_my_memdup(const void *from, size_t length, const char *filename, - uint lineno, myf MyFlags) -{ - void *ptr; - if ((ptr= _mymalloc(length,filename,lineno,MyFlags)) != 0) - memcpy(ptr, from, length); - return(ptr); -} /*_my_memdup */ - - -char *_my_strdup(const char *from, const char *filename, uint lineno, - myf MyFlags) -{ - 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, size_t length, - const char *filename, uint lineno, - myf MyFlags) -{ - char *ptr; - if ((ptr= (char*) _mymalloc(length+1,filename,lineno,MyFlags)) != 0) - { - memcpy((uchar*) ptr, (uchar*) from, (size_t) length); - ptr[length]=0; - } - return(ptr); -} diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c index f1b96cd03da..675910d2b20 100644 --- a/mysys/stacktrace.c +++ b/mysys/stacktrace.c @@ -334,44 +334,9 @@ void my_write_core(int sig) #include <dbghelp.h> #include <tlhelp32.h> - -/* - Stack tracing on Windows is implemented using Debug Helper library(dbghelp.dll) - We do not redistribute dbghelp and the one comes with older OS (up to Windows 2000) - is missing some important functions like functions StackWalk64 or MinidumpWriteDump. - Hence, we have to load functions at runtime using LoadLibrary/GetProcAddress. -*/ - -typedef DWORD (WINAPI *SymSetOptions_FctType)(DWORD dwOptions); -typedef BOOL (WINAPI *SymGetModuleInfo64_FctType) - (HANDLE,DWORD64,PIMAGEHLP_MODULE64) ; -typedef BOOL (WINAPI *SymGetSymFromAddr64_FctType) - (HANDLE,DWORD64,PDWORD64,PIMAGEHLP_SYMBOL64) ; -typedef BOOL (WINAPI *SymGetLineFromAddr64_FctType) - (HANDLE,DWORD64,PDWORD,PIMAGEHLP_LINE64); -typedef BOOL (WINAPI *SymInitialize_FctType) - (HANDLE,PSTR,BOOL); -typedef BOOL (WINAPI *StackWalk64_FctType) - (DWORD,HANDLE,HANDLE,LPSTACKFRAME64,PVOID,PREAD_PROCESS_MEMORY_ROUTINE64, - PFUNCTION_TABLE_ACCESS_ROUTINE64,PGET_MODULE_BASE_ROUTINE64 , - PTRANSLATE_ADDRESS_ROUTINE64); -typedef BOOL (WINAPI *MiniDumpWriteDump_FctType)( - IN HANDLE hProcess, - IN DWORD ProcessId, - IN HANDLE hFile, - IN MINIDUMP_TYPE DumpType, - IN CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, OPTIONAL - IN CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, OPTIONAL - IN CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam OPTIONAL - ); - -static SymSetOptions_FctType pSymSetOptions; -static SymGetModuleInfo64_FctType pSymGetModuleInfo64; -static SymGetSymFromAddr64_FctType pSymGetSymFromAddr64; -static SymInitialize_FctType pSymInitialize; -static StackWalk64_FctType pStackWalk64; -static SymGetLineFromAddr64_FctType pSymGetLineFromAddr64; -static MiniDumpWriteDump_FctType pMiniDumpWriteDump; +#if _MSC_VER +#pragma comment(lib, "dbghelp") +#endif static EXCEPTION_POINTERS *exception_ptrs; @@ -382,50 +347,24 @@ void my_init_stacktrace() { } -/* - Dynamically load dbghelp functions -*/ -BOOL init_dbghelp_functions() -{ - static BOOL first_time= TRUE; - static BOOL rc; - HMODULE hDbghlp; - - if(first_time) - { - first_time= FALSE; - hDbghlp= LoadLibrary("dbghelp"); - if(!hDbghlp) - { - rc= FALSE; - return rc; - } - pSymSetOptions= (SymSetOptions_FctType) - GetProcAddress(hDbghlp,"SymSetOptions"); - pSymInitialize= (SymInitialize_FctType) - GetProcAddress(hDbghlp,"SymInitialize"); - pSymGetModuleInfo64= (SymGetModuleInfo64_FctType) - GetProcAddress(hDbghlp,"SymGetModuleInfo64"); - pSymGetLineFromAddr64= (SymGetLineFromAddr64_FctType) - GetProcAddress(hDbghlp,"SymGetLineFromAddr64"); - pSymGetSymFromAddr64=(SymGetSymFromAddr64_FctType) - GetProcAddress(hDbghlp,"SymGetSymFromAddr64"); - pStackWalk64= (StackWalk64_FctType) - GetProcAddress(hDbghlp,"StackWalk64"); - pMiniDumpWriteDump = (MiniDumpWriteDump_FctType) - GetProcAddress(hDbghlp,"MiniDumpWriteDump"); - - rc = (BOOL)(pSymSetOptions && pSymInitialize && pSymGetModuleInfo64 - && pSymGetLineFromAddr64 && pSymGetSymFromAddr64 && pStackWalk64); - } - return rc; -} void my_set_exception_pointers(EXCEPTION_POINTERS *ep) { exception_ptrs = ep; } +/* + Appends directory to symbol path. +*/ +static void add_to_symbol_path(char *path, size_t path_buffer_size, + char *dir, size_t dir_buffer_size) +{ + strcat_s(dir, dir_buffer_size, ";"); + if (!strstr(path, dir)) + { + strcat_s(path, path_buffer_size, dir); + } +} /* Get symbol path - semicolon-separated list of directories to search for debug @@ -437,8 +376,28 @@ static void get_symbol_path(char *path, size_t size) { HANDLE hSnap; char *envvar; + char *p; +#ifndef DBUG_OFF + static char pdb_debug_dir[MAX_PATH + 7]; +#endif path[0]= '\0'; + +#ifndef DBUG_OFF + /* + Add "debug" subdirectory of the application directory, sometimes PDB will + placed here by installation. + */ + GetModuleFileName(NULL, pdb_debug_dir, MAX_PATH); + p= strrchr(pdb_debug_dir, '\\'); + if(p) + { + *p= 0; + strcat_s(pdb_debug_dir, sizeof(pdb_debug_dir), "\\debug;"); + add_to_symbol_path(path, size, pdb_debug_dir, sizeof(pdb_debug_dir)); + } +#endif + /* Enumerate all modules, and add their directories to the path. Avoid duplicate entries. @@ -452,7 +411,7 @@ static void get_symbol_path(char *path, size_t size) for (ret= Module32First(hSnap, &mod); ret; ret= Module32Next(hSnap, &mod)) { char *module_dir= mod.szExePath; - char *p= strrchr(module_dir,'\\'); + p= strrchr(module_dir,'\\'); if (!p) { /* @@ -460,29 +419,23 @@ static void get_symbol_path(char *path, size_t size) will indicate current directory. */ module_dir[0]= '.'; - p= module_dir + 1; + module_dir[1]= '\0'; } - *p++= ';'; - *p= '\0'; - - if (!strstr(path, module_dir)) + else { - size_t dir_len = strlen(module_dir); - if (size > dir_len) - { - strncat(path, module_dir, size-1); - size -= dir_len; - } + *p= '\0'; } + add_to_symbol_path(path, size, module_dir,sizeof(mod.szExePath)); } CloseHandle(hSnap); } + /* Add _NT_SYMBOL_PATH, if present. */ envvar= getenv("_NT_SYMBOL_PATH"); - if(envvar && size) + if(envvar) { - strncat(path, envvar, size-1); + strcat_s(path, size, envvar); } } @@ -506,15 +459,15 @@ void my_print_stacktrace(uchar* unused1, ulong unused2) STACKFRAME64 frame={0}; static char symbol_path[MAX_SYMBOL_PATH]; - if(!exception_ptrs || !init_dbghelp_functions()) + if(!exception_ptrs) return; /* Copy context, as stackwalking on original will unwind the stack */ context = *(exception_ptrs->ContextRecord); /*Initialize symbols.*/ - pSymSetOptions(SYMOPT_LOAD_LINES|SYMOPT_NO_PROMPTS|SYMOPT_DEFERRED_LOADS|SYMOPT_DEBUG); + SymSetOptions(SYMOPT_LOAD_LINES|SYMOPT_NO_PROMPTS|SYMOPT_DEFERRED_LOADS|SYMOPT_DEBUG); get_symbol_path(symbol_path, sizeof(symbol_path)); - pSymInitialize(hProcess, symbol_path, TRUE); + SymInitialize(hProcess, symbol_path, TRUE); /*Prepare stackframe for the first StackWalk64 call*/ frame.AddrFrame.Mode= frame.AddrPC.Mode= frame.AddrStack.Mode= AddrModeFlat; @@ -546,11 +499,11 @@ void my_print_stacktrace(uchar* unused1, ulong unused2) BOOL have_symbol= FALSE; BOOL have_source= FALSE; - if(!pStackWalk64(machine, hProcess, hThread, &frame, &context, 0, 0, 0 ,0)) + if(!StackWalk64(machine, hProcess, hThread, &frame, &context, 0, 0, 0 ,0)) break; addr= frame.AddrPC.Offset; - have_module= pSymGetModuleInfo64(hProcess,addr,&module); + have_module= SymGetModuleInfo64(hProcess,addr,&module); #ifdef _M_IX86 if(!have_module) { @@ -560,13 +513,13 @@ void my_print_stacktrace(uchar* unused1, ulong unused2) happy, pretend passing the old structure. */ module.SizeOfStruct= MODULE64_SIZE_WINXP; - have_module= pSymGetModuleInfo64(hProcess, addr, &module); + have_module= SymGetModuleInfo64(hProcess, addr, &module); } #endif - have_symbol= pSymGetSymFromAddr64(hProcess, addr, &function_offset, + have_symbol= SymGetSymFromAddr64(hProcess, addr, &function_offset, &(package.sym)); - have_source= pSymGetLineFromAddr64(hProcess, addr, &line_offset, &line); + have_source= SymGetLineFromAddr64(hProcess, addr, &line_offset, &line); fprintf(stderr, "%p ", addr); if(have_module) @@ -610,7 +563,7 @@ void my_write_core(int unused) MINIDUMP_EXCEPTION_INFORMATION info; HANDLE hFile; - if(!exception_ptrs || !init_dbghelp_functions() || !pMiniDumpWriteDump) + if(!exception_ptrs) return; info.ExceptionPointers= exception_ptrs; @@ -628,7 +581,7 @@ void my_write_core(int unused) if(hFile) { /* Create minidump */ - if(pMiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), + if(MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &info, 0, 0)) { fprintf(stderr, "Minidump written to %s\n", diff --git a/mysys/string.c b/mysys/string.c index 10a72b8a295..b1eded0664c 100644 --- a/mysys/string.c +++ b/mysys/string.c @@ -177,9 +177,6 @@ my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...) void dynstr_free(DYNAMIC_STRING *str) { - if (str->str) - { - my_free(str->str,MYF(MY_WME)); - str->str=0; - } + my_free(str->str); + str->str= NULL; } diff --git a/mysys/test_charset.c b/mysys/test_charset.c index d867b49304e..5b399071d11 100644 --- a/mysys/test_charset.c +++ b/mysys/test_charset.c @@ -80,11 +80,11 @@ int main(int argc, char **argv) { #ifdef NOT_USED_ANYMORE cs_list = list_charsets(MYF(MY_CS_COMPILED | MY_CS_CONFIG)); printf("LIST OF CHARSETS (compiled + *.conf):\n%s\n", cs_list); - my_free(cs_list,MYF(0)); + my_free(cs_list); cs_list = list_charsets(MYF(MY_CS_INDEX | MY_CS_LOADED)); printf("LIST OF CHARSETS (index + loaded):\n%s\n", cs_list); - my_free(cs_list,MYF(0)); + my_free(cs_list); #endif return 0; diff --git a/mysys/testhash.c b/mysys/testhash.c index 2add2ebd2d7..376303f29be 100644 --- a/mysys/testhash.c +++ b/mysys/testhash.c @@ -286,5 +286,5 @@ static int rnd(int max_value) void free_record(void *record) { - my_free(record,MYF(0)); + my_free(record); } diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index c6f9480b791..9ca18eeaf1b 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -262,7 +262,7 @@ void thr_end_alarm(thr_alarm_t *alarmed) { queue_remove(&alarm_queue,i),MYF(0); if (alarm_data->malloced) - my_free((uchar*) alarm_data,MYF(0)); + my_free(alarm_data); found++; #ifdef DBUG_OFF break; diff --git a/mysys/tree.c b/mysys/tree.c index ef33f75b7c6..8ea7102ed4c 100644 --- a/mysys/tree.c +++ b/mysys/tree.c @@ -183,7 +183,7 @@ static void delete_tree_element(TREE *tree, TREE_ELEMENT *element) (*tree->free)(ELEMENT_KEY(tree,element), free_free, tree->custom_arg); delete_tree_element(tree,element->right); if (tree->with_delete) - my_free((char*) element,MYF(0)); + my_free(element); } } @@ -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((uchar*) element,MYF(0)); + my_free(element); tree->elements_in_tree--; return 0; } diff --git a/mysys/trie.c b/mysys/trie.c index 5738b9b866b..b2e93fcceac 100644 --- a/mysys/trie.c +++ b/mysys/trie.c @@ -211,7 +211,7 @@ my_bool ac_trie_prepare (TRIE *trie) fail= fail->fail; } } - my_free((uchar*)tmp_nodes, MYF(0)); + my_free(tmp_nodes); DBUG_RETURN(FALSE); } |