summaryrefslogtreecommitdiff
path: root/mysys/tree.c
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2004-03-04 08:50:37 +0200
committerunknown <monty@mashka.mysql.fi>2004-03-04 08:50:37 +0200
commitafa6728a9f7c00582b3dc9e96b2dce5c4ac1e56c (patch)
treef335ad0e2c6634a947a95d62cbee9a54ee9303e8 /mysys/tree.c
parentf96960f9e1605189cc49397c64ff1cff97faedf1 (diff)
downloadmariadb-git-afa6728a9f7c00582b3dc9e96b2dce5c4ac1e56c.tar.gz
Optimized GIS functions
heap/hp_delete.c: Added comments mysql-test/r/gis.result: Updated results after name changes (all results line are unchanged) mysql-test/r/show_check.result: Update test results after fix in hp_delete.cc mysql-test/t/gis.test: Changed table names to longer, hopefully non conflicting ones. Added missing drop table mysys/hash.c: Inendation cleanup mysys/tree.c: Updated comments Decrease tree->allocated on delete (for status) sql/field.cc: Added safety checking for GIS objects sql/gstream.cc: Added copyright message Made a lot of speed/space optimizations Changed class names to be MySQL compliant sql/gstream.h: Made a lot of speed/space optimizations Changed class names to be MySQL compliant sql/item_create.cc: Indentation fixup sql/item_geofunc.cc: Use new gis interface functions and new gis class names. Simple optimizations Indentation fixups Fixed a lot of unlikely but possible errors. sql/item_geofunc.h: Moved SRID_SIZE to spatial.h sql/spatial.cc: Added copyright message Made a lot of speed/space optimizations Changed class names to be MySQL compliant sql/spatial.h: Made a lot of speed/space optimizations Changed class names to be MySQL compliant Indentation fixes Use bool instead of int as result type for functions that only return 0 or 1 sql/sql_string.cc: Simple optimizations sql/sql_string.h: Simple cleanups sql/structs.h: Added LEX_STRING_WITH_INIT (needed by spatial.cc)
Diffstat (limited to 'mysys/tree.c')
-rw-r--r--mysys/tree.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/mysys/tree.c b/mysys/tree.c
index 42c58131100..0b30ffa4971 100644
--- a/mysys/tree.c
+++ b/mysys/tree.c
@@ -170,8 +170,8 @@ void delete_tree(TREE* tree)
void reset_tree(TREE* tree)
{
+ /* do not free mem_root, just mark blocks as free */
free_tree(tree, MYF(MY_MARK_BLOCKS_FREE));
- /* do not my_free() mem_root if applicable, just mark blocks as free */
}
@@ -188,10 +188,14 @@ static void delete_tree_element(TREE *tree, TREE_ELEMENT *element)
}
}
- /* Code for insert, search and delete of elements */
- /* parent[0] = & parent[-1][0]->left ||
- parent[0] = & parent[-1][0]->right */
+/*
+ insert, search and delete of elements
+
+ The following should be true:
+ parent[0] = & parent[-1][0]->left ||
+ parent[0] = & parent[-1][0]->right
+*/
TREE_ELEMENT *tree_insert(TREE *tree, void *key, uint key_size,
void* custom_arg)
@@ -232,8 +236,7 @@ TREE_ELEMENT *tree_insert(TREE *tree, void *key, uint key_size,
if (tree->with_delete)
element=(TREE_ELEMENT *) my_malloc(alloc_size, MYF(MY_WME));
else
- element=(TREE_ELEMENT *)
- alloc_root(&tree->mem_root,alloc_size);
+ element=(TREE_ELEMENT *) alloc_root(&tree->mem_root,alloc_size);
if (!element)
return(NULL);
**parent=element;
@@ -251,9 +254,9 @@ TREE_ELEMENT *tree_insert(TREE *tree, void *key, uint key_size,
}
else
memcpy((byte*) element+tree->offset_to_key,key,(size_t) key_size);
- element->count=1; /* May give warning in purify */
+ element->count=1; /* May give warning in purify */
tree->elements_in_tree++;
- rb_insert(tree,parent,element); /* rebalance tree */
+ rb_insert(tree,parent,element); /* rebalance tree */
}
else
{
@@ -320,6 +323,8 @@ int tree_delete(TREE *tree, void *key, void *custom_arg)
rb_delete_fixup(tree,parent);
if (tree->free)
(*tree->free)(ELEMENT_KEY(tree,element), free_free, tree->custom_arg);
+ /* This doesn't include key_size, but better than nothing */
+ tree->allocated-= sizeof(TREE_ELEMENT)+tree->size_of_element;
my_free((gptr) element,MYF(0));
tree->elements_in_tree--;
return 0;