diff options
author | He Zhenxing <hezx@mysql.com> | 2008-09-06 08:51:17 +0800 |
---|---|---|
committer | He Zhenxing <hezx@mysql.com> | 2008-09-06 08:51:17 +0800 |
commit | b17458dcc14882dcb2565bcbb92115ed786fe7c1 (patch) | |
tree | 81eaef221aa476a0279c43f5e5c6df9c91924e44 /mysys | |
parent | d0edf322306221f2e662a54a9feecc78378d6dfe (diff) | |
parent | d70d171ceef259920d975fa2ddccaa6a41ba91fe (diff) | |
download | mariadb-git-b17458dcc14882dcb2565bcbb92115ed786fe7c1.tar.gz |
Merge 5.1 main -> 5.1-rpl
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/mf_pack.c | 2 | ||||
-rw-r--r-- | mysys/my_static.c | 4 | ||||
-rw-r--r-- | mysys/my_static.h | 2 | ||||
-rw-r--r-- | mysys/my_symlink.c | 55 | ||||
-rw-r--r-- | mysys/safemalloc.c | 53 | ||||
-rw-r--r-- | mysys/thr_lock.c | 2 |
6 files changed, 64 insertions, 54 deletions
diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c index bed9968063a..d4828946d82 100644 --- a/mysys/mf_pack.c +++ b/mysys/mf_pack.c @@ -354,7 +354,7 @@ size_t unpack_dirname(char * to, const char *from) length-= (size_t) (suffix-buff)-1; if (length+(h_length= strlen(tilde_expansion)) <= FN_REFLEN) { - if (tilde_expansion[h_length-1] == FN_LIBCHAR) + if ((h_length > 0) && (tilde_expansion[h_length-1] == FN_LIBCHAR)) h_length--; if (buff+h_length < suffix) bmove(buff+h_length,suffix,length); diff --git a/mysys/my_static.c b/mysys/my_static.c index cb482b19b57..d0c20da828a 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -70,8 +70,8 @@ uint sf_malloc_prehunc=0, /* If you have problem with core- */ sf_malloc_endhunc=0, /* dump when malloc-message.... */ /* set theese to 64 or 128 */ sf_malloc_quick=0; /* set if no calls to sanity */ -ulong sf_malloc_cur_memory= 0L; /* Current memory usage */ -ulong sf_malloc_max_memory= 0L; /* Maximum memory usage */ +size_t sf_malloc_cur_memory= 0L; /* Current memory usage */ +size_t sf_malloc_max_memory= 0L; /* Maximum memory usage */ uint sf_malloc_count= 0; /* Number of times NEW() was called */ uchar *sf_min_adress= (uchar*) ~(unsigned long) 0L, *sf_max_adress= (uchar*) 0L; diff --git a/mysys/my_static.h b/mysys/my_static.h index 0eca196c1c9..90168b099a8 100644 --- a/mysys/my_static.h +++ b/mysys/my_static.h @@ -44,8 +44,8 @@ struct st_irem struct st_irem *next; /* Linked list of structures */ struct st_irem *prev; /* Other link */ char *filename; /* File in which memory was new'ed */ + size_t datasize; /* Size requested */ uint32 linenum; /* Line number in above file */ - uint32 datasize; /* Size requested */ uint32 SpecialValue; /* Underrun marker value */ }; diff --git a/mysys/my_symlink.c b/mysys/my_symlink.c index 98059ccd508..f8c6ebf02c3 100644 --- a/mysys/my_symlink.c +++ b/mysys/my_symlink.c @@ -108,38 +108,47 @@ int my_symlink(const char *content, const char *linkname, myf MyFlags) #define BUFF_LEN FN_LEN #endif + +int my_is_symlink(const char *filename __attribute__((unused))) +{ +#if defined (HAVE_LSTAT) && defined (S_ISLNK) + struct stat stat_buff; + return !lstat(filename, &stat_buff) && S_ISLNK(stat_buff.st_mode); +#elif defined (_WIN32) + DWORD dwAttr = GetFileAttributes(filename); + return (dwAttr != INVALID_FILE_ATTRIBUTES) && + (dwAttr & FILE_ATTRIBUTE_REPARSE_POINT); +#else /* No symlinks */ + return 0; +#endif +} + + int my_realpath(char *to, const char *filename, myf MyFlags __attribute__((unused))) { #if defined(HAVE_REALPATH) && !defined(HAVE_purify) && !defined(HAVE_BROKEN_REALPATH) int result=0; char buff[BUFF_LEN]; - struct stat stat_buff; + char *ptr; DBUG_ENTER("my_realpath"); - if (!(MyFlags & MY_RESOLVE_LINK) || - (!lstat(filename,&stat_buff) && S_ISLNK(stat_buff.st_mode))) - { - char *ptr; - DBUG_PRINT("info",("executing realpath")); - if ((ptr=realpath(filename,buff))) - { + DBUG_PRINT("info",("executing realpath")); + if ((ptr=realpath(filename,buff))) strmake(to,ptr,FN_REFLEN-1); - } - else - { - /* - Realpath didn't work; Use my_load_path() which is a poor substitute - original name but will at least be able to resolve paths that starts - with '.'. - */ - DBUG_PRINT("error",("realpath failed with errno: %d", errno)); - my_errno=errno; - if (MyFlags & MY_WME) - my_error(EE_REALPATH, MYF(0), filename, my_errno); - my_load_path(to, filename, NullS); - result= -1; - } + else + { + /* + Realpath didn't work; Use my_load_path() which is a poor substitute + original name but will at least be able to resolve paths that starts + with '.'. + */ + DBUG_PRINT("error",("realpath failed with errno: %d", errno)); + my_errno=errno; + if (MyFlags & MY_WME) + my_error(EE_REALPATH, MYF(0), filename, my_errno); + my_load_path(to, filename, NullS); + result= -1; } DBUG_RETURN(result); #else diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c index a7a7bcc9c53..905733524e3 100644 --- a/mysys/safemalloc.c +++ b/mysys/safemalloc.c @@ -151,9 +151,10 @@ void *_mymalloc(size_t size, const char *filename, uint lineno, myf MyFlags) my_errno=errno; sprintf(buff,"Out of memory at line %d, '%s'", lineno, filename); my_message(EE_OUTOFMEMORY, buff, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH)); - sprintf(buff,"needed %u byte (%ldk), memory in use: %ld bytes (%ldk)", - (uint) size, (uint) (size + 1023L) / 1024L, - sf_malloc_max_memory, (sf_malloc_max_memory + 1023L) / 1024L); + 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'", @@ -193,7 +194,7 @@ void *_mymalloc(size_t size, const char *filename, uint lineno, myf MyFlags) if ((MyFlags & MY_ZEROFILL) || !sf_malloc_quick) bfill(data, size, (char) (MyFlags & MY_ZEROFILL ? 0 : ALLOC_VAL)); /* Return a pointer to the real data */ - DBUG_PRINT("exit",("ptr: 0x%lx", (long) data)); + DBUG_PRINT("exit",("ptr: %p", data)); if (sf_min_adress > data) sf_min_adress= data; if (sf_max_adress < data) @@ -258,7 +259,7 @@ void _myfree(void *ptr, const char *filename, uint lineno, myf myflags) { struct st_irem *irem; DBUG_ENTER("_myfree"); - DBUG_PRINT("enter",("ptr: 0x%lx", (long) ptr)); + DBUG_PRINT("enter",("ptr: %p", ptr)); if (!sf_malloc_quick) (void) _sanity (filename, lineno); @@ -391,12 +392,12 @@ void TERMINATE(FILE *file, uint flag) { if (file) { - fprintf(file, "Warning: Memory that was not free'ed (%ld bytes):\n", - sf_malloc_cur_memory); + 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 (%ld bytes):", - sf_malloc_cur_memory)); + 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)) + @@ -404,27 +405,29 @@ void TERMINATE(FILE *file, uint flag) if (file) { fprintf(file, - "\t%6u bytes at 0x%09lx, allocated at line %4u in '%s'", - irem->datasize, (long) data, irem->linenum, irem->filename); + "\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", - ("%6u bytes at 0x%09lx, allocated at line %4d in '%s'", - irem->datasize, (long) data, irem->linenum, irem->filename)); + ("%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: %ld bytes (%ldk)\n", - sf_malloc_max_memory, (sf_malloc_max_memory + 1023L) / 1024L); + 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: %ld bytes (%ldk)", - sf_malloc_max_memory, (sf_malloc_max_memory + 1023L) / - 1024L)); + DBUG_PRINT("safe",("Maximum memory usage: %lu bytes (%luk)", + (ulong) sf_malloc_max_memory, + (ulong) (sf_malloc_max_memory + 1023L) /1024L)); pthread_mutex_unlock(&THR_LOCK_malloc); DBUG_VOID_RETURN; } @@ -446,8 +449,8 @@ void sf_malloc_report_allocated(void *memory) sf_malloc_prehunc); if (data <= (char*) memory && (char*) memory <= data + irem->datasize) { - printf("%u bytes at 0x%lx, allocated at line %u in '%s'\n", - irem->datasize, (long) data, irem->linenum, irem->filename); + printf("%lu bytes at %p, allocated at line %u in '%s'\n", + (ulong) irem->datasize, data, irem->linenum, irem->filename); break; } } @@ -470,8 +473,8 @@ static int _checkchunk(register struct st_irem *irem, const char *filename, irem->filename, irem->linenum); fprintf(stderr, " discovered at %s:%d\n", filename, lineno); (void) fflush(stderr); - DBUG_PRINT("safe",("Underrun at 0x%lx, allocated at %s:%d", - (long) data, irem->filename, irem->linenum)); + DBUG_PRINT("safe",("Underrun at %p, allocated at %s:%d", + data, irem->filename, irem->linenum)); flag=1; } @@ -486,10 +489,8 @@ static int _checkchunk(register struct st_irem *irem, const char *filename, irem->filename, irem->linenum); fprintf(stderr, " discovered at '%s:%d'\n", filename, lineno); (void) fflush(stderr); - DBUG_PRINT("safe",("Overrun at 0x%lx, allocated at %s:%d", - (long) data, - irem->filename, - irem->linenum)); + DBUG_PRINT("safe",("Overrun at %p, allocated at %s:%d", + data, irem->filename, irem->linenum)); flag=1; } return(flag); diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index 55b95407db5..b13e8411771 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -333,10 +333,10 @@ void thr_lock_init(THR_LOCK *lock) void thr_lock_delete(THR_LOCK *lock) { DBUG_ENTER("thr_lock_delete"); - VOID(pthread_mutex_destroy(&lock->mutex)); pthread_mutex_lock(&THR_LOCK_lock); thr_lock_thread_list=list_delete(thr_lock_thread_list,&lock->list); pthread_mutex_unlock(&THR_LOCK_lock); + pthread_mutex_destroy(&lock->mutex); DBUG_VOID_RETURN; } |