diff options
author | unknown <monty@hundin.mysql.fi> | 2001-05-31 14:08:00 +0300 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2001-05-31 14:08:00 +0300 |
commit | ef678c6ab4b1dbbb47b558e4fc1594cdd2a74f69 (patch) | |
tree | 5ae8949b2638cedd01e60fb4a20e771b15c3d3b0 /mysys | |
parent | e6ecbfd629bf92c84f270119405f4796464e7f4e (diff) | |
parent | d9a9f38e870f24c4bc148ed58333abaedad81f05 (diff) | |
download | mariadb-git-ef678c6ab4b1dbbb47b558e4fc1594cdd2a74f69.tar.gz |
Merge work:/home/bk/mysql-4.0 into hundin.mysql.fi:/my/bk/mysql-4.0
BitKeeper/etc/logging_ok:
auto-union
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/mf_cache.c | 3 | ||||
-rw-r--r-- | mysys/mf_format.c | 29 | ||||
-rw-r--r-- | mysys/my_alloc.c | 69 |
3 files changed, 39 insertions, 62 deletions
diff --git a/mysys/mf_cache.c b/mysys/mf_cache.c index ff29926ac50..4b8fc6fed17 100644 --- a/mysys/mf_cache.c +++ b/mysys/mf_cache.c @@ -28,7 +28,8 @@ this, just remember the file name for later removal */ -static my_bool cache_remove_open_tmp(IO_CACHE *cache, const char *name) +static my_bool cache_remove_open_tmp(IO_CACHE *cache __attribute__((unused)), + const char *name) { #if O_TEMPORARY == 0 #if !defined(CANT_DELETE_OPEN_FILES) diff --git a/mysys/mf_format.c b/mysys/mf_format.c index c4425806e01..216608fdee5 100644 --- a/mysys/mf_format.c +++ b/mysys/mf_format.c @@ -17,10 +17,6 @@ #include "mysys_priv.h" #include <m_string.h> -#ifdef HAVE_REALPATH -#include <sys/param.h> -#include <sys/stat.h> -#endif /* format a filename with replace of library and extension */ /* params to and name may be identicall */ @@ -33,21 +29,12 @@ /* 32 Resolve filename to full path */ /* 64 Return NULL if too long path */ -#ifdef SCO -#define BUFF_LEN 4097 -#else -#ifdef MAXPATHLEN -#define BUFF_LEN MAXPATHLEN -#else -#define BUFF_LEN FN_LEN -#endif -#endif my_string fn_format(my_string to, const char *name, const char *dsk, const char *form, int flag) { reg1 uint length; - char dev[FN_REFLEN], buff[BUFF_LEN], *pos, *startpos; + char dev[FN_REFLEN], buff[FN_REFLEN], *pos, *startpos; const char *ext; DBUG_ENTER("fn_format"); DBUG_PRINT("enter",("name: %s dsk: %s form: %s flag: %d", @@ -109,18 +96,14 @@ my_string fn_format(my_string to, const char *name, const char *dsk, #endif (void) strmov(pos,ext); /* Don't convert extension */ } - /* Purify gives a lot of UMR errors when using realpath */ -#if defined(HAVE_REALPATH) && !defined(HAVE_purify) && !defined(HAVE_BROKEN_REALPATH) if (flag & 16) { - struct stat stat_buff; - if (flag & 32 || (!lstat(to,&stat_buff) && S_ISLNK(stat_buff.st_mode))) - { - if (realpath(to,buff)) - strmake(to,buff,FN_REFLEN-1); - } + strmov(buff,to); + my_symlink(to, buff, MYF(flag & 32 ? 0 : MY_RESOLVE_LINK)); } -#endif + else if (flag & 32) + my_realpath(to, to, MYF(flag & 32 ? 0 : MY_RESOLVE_LINK)); + DBUG_RETURN (to); } /* fn_format */ diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c index b82ff965dfb..ffbed381226 100644 --- a/mysys/my_alloc.c +++ b/mysys/my_alloc.c @@ -100,41 +100,34 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size) #endif } +/* Mark all data in blocks free for reusage */ + static inline void mark_blocks_free(MEM_ROOT* root) { - reg1 USED_MEM *next,*last = 0; + reg1 USED_MEM *next; + reg2 USED_MEM **last; - /* iterate through (partially) free blocks, mark them fully free */ - for(next = root->free; next; next = next->next ) - { - last = next; - next->left = next->size - ALIGN_SIZE(sizeof(USED_MEM)); - } - /* if free block list was not empty, point the next of the - last free block to the beginning of the used list */ - next = root->used; /* a little optimization to avoid dereferencing root - twice - we will shortly start iterating through used - list */ - if(last) - last->next = next; - else /* if free list is empty, just point it to the current used*/ - root->free = next; - - /* now go through the current used list, and mark each block - as fully free. Note that because of our optimization, we do not - need to initialize next here - see above - */ - for(;next; next = next->next) - next->left = next->size - ALIGN_SIZE(sizeof(USED_MEM)); - - /* Now everything is set - we just need to indicate that nothing is used - anymore - */ - root->used = 0; + /* iterate through (partially) free blocks, mark them free */ + last= &root->free; + for (next= root->free; next; next= *(last= &next->next)) + next->left= next->size - ALIGN_SIZE(sizeof(USED_MEM)); + + /* Combine the free and the used list */ + *last= next=root->used; + + /* now go through the used blocks and mark them free */ + for (; next; next= next->next) + next->left= next->size - ALIGN_SIZE(sizeof(USED_MEM)); + + /* Now everything is set; Indicate that nothing is used anymore */ + root->used= 0; } - /* deallocate everything used by alloc_root or just move - used blocks to free list if called with MY_USED_TO_FREE */ + +/* + Deallocate everything used by alloc_root or just move + used blocks to free list if called with MY_USED_TO_FREE +*/ void free_root(MEM_ROOT *root, myf MyFlags) { @@ -143,23 +136,23 @@ void free_root(MEM_ROOT *root, myf MyFlags) if (!root) DBUG_VOID_RETURN; /* purecov: inspected */ - if(MyFlags & MY_MARK_BLOCKS_FREE) - { - mark_blocks_free(root); - DBUG_VOID_RETURN; - } + if (MyFlags & MY_MARK_BLOCKS_FREE) + { + mark_blocks_free(root); + DBUG_VOID_RETURN; + } if (!(MyFlags & MY_KEEP_PREALLOC)) root->pre_alloc=0; - for ( next=root->used; next ;) + for (next=root->used; next ;) { old=next; next= next->next ; if (old != root->pre_alloc) my_free((gptr) old,MYF(0)); } - for (next= root->free ; next ; ) + for (next=root->free ; next ;) { - old=next; next= next->next ; + old=next; next= next->next; if (old != root->pre_alloc) my_free((gptr) old,MYF(0)); } |