summaryrefslogtreecommitdiff
path: root/mysys/my_alloc.c
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2001-05-31 14:07:17 +0300
committerunknown <monty@hundin.mysql.fi>2001-05-31 14:07:17 +0300
commita178584d8a8a81e461c1107f8558ee6233258ce5 (patch)
treef19c68fd5b7d68ad4f7919cb8e6eae7d6961956e /mysys/my_alloc.c
parentbc50c5787e98e5d6c0d84013254a388f2ebf7f9b (diff)
downloadmariadb-git-a178584d8a8a81e461c1107f8558ee6233258ce5.tar.gz
Removed compiler warnings.
Added preliminary handling of symlinks in MyISAM. When using myisamchk to check tables with --force, don't repair tables that are marked as 'not closed' if they are ok. Change fn_format() to use my_real_path and my_symlink include/myisam.h: Added handling of symlinks myisam/ft_boolean_search.c: cleanup myisam/ft_dump.c: cleanup myisam/mi_check.c: Added handling of symlinks. When using check and --force, don't repair tables that are marked as 'not closed' if they are ok. myisam/mi_create.c: Added handling of symlinks. myisam/mi_dbug.c: Added handling of symlinks. myisam/mi_info.c: Added handling of symlinks. myisam/mi_open.c: Added handling of symlinks. myisam/mi_search.c: cleanup myisam/myisamchk.c: Added handling of symlinks. myisam/myisamdef.h: Added handling of symlinks. myisam/myisamlog.c: Fixed bug when using new trees myisam/myisampack.c: cleanup mysys/mf_cache.c: cleanup mysys/mf_format.c: Change to use my_real_path and my_symlink mysys/my_alloc.c: cleanup BitKeeper/etc/ignore: Added libmysqld/sql_command libmysqld/backup_dir libmysqld/simple-test to the ignore list BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
Diffstat (limited to 'mysys/my_alloc.c')
-rw-r--r--mysys/my_alloc.c69
1 files changed, 31 insertions, 38 deletions
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));
}