mirror of
https://gitee.com/apaki/unicstl.git
synced 2025-05-18 03:51:35 +08:00
修改cmake偶尔报异常的问题
This commit is contained in:
parent
fba69551b5
commit
7ba86577b1
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
# 0. cmake 最低版本号要求
|
# 0. cmake 最低版本号要求
|
||||||
cmake_minimum_required(VERSION 3.8)
|
cmake_minimum_required(VERSION 3.28)
|
||||||
|
|
||||||
# 0. 项目信息
|
# 0. 项目信息
|
||||||
project(demo)
|
project(demo)
|
||||||
|
3
mk.bat
3
mk.bat
@ -1,7 +1,8 @@
|
|||||||
@REM D:\Lang\cmake-3.27.5-windows-x86_64\bin\cmake.EXE --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=D:\Software\mingw64\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=D:\Software\mingw64\bin\g++.exe -SF:/OpenDemo/1_vsc_cmake -Bf:/OpenDemo/1_vsc_cmake/build -G "MinGW Makefiles"
|
@REM D:\Lang\cmake-3.27.5-windows-x86_64\bin\cmake.EXE --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=D:\Software\mingw64\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=D:\Software\mingw64\bin\g++.exe -SF:/OpenDemo/1_vsc_cmake -Bf:/OpenDemo/1_vsc_cmake/build -G "MinGW Makefiles"
|
||||||
@REM cmake -Bbuild -G "Visual Studio 17 2022"
|
@REM cmake -Bbuild -G "Visual Studio 17 2022"
|
||||||
|
|
||||||
cmake -B build -G "MinGW Makefiles"
|
@REM cmake -B build -G "MinGW Makefiles"
|
||||||
|
cmake -B build -G "Unix Makefiles"
|
||||||
|
|
||||||
make -C build
|
make -C build
|
||||||
make -C build install
|
make -C build install
|
||||||
|
21
src/tree.c
21
src/tree.c
@ -1496,10 +1496,10 @@ static void tree_set_balance(struct _tree* self, struct _tree_node * node)
|
|||||||
*
|
*
|
||||||
* | Çé¿ö | root->balance | node->balance | µ÷Õû·½Ê½ |
|
* | Çé¿ö | root->balance | node->balance | µ÷Õû·½Ê½ |
|
||||||
* | ---- | ------------ | -------------- | -------- |
|
* | ---- | ------------ | -------------- | -------- |
|
||||||
* | 1 | > 0 | > 0 | ×óĐý
|
* | 1 | > 1 | > 0 | ×óÐý
|
||||||
* | 2 | > 0 | < 0 | ĎČÓŇĐýşó×óĐý
|
* | 2 | > 1 | < 0 | ÏÈÓÒÐýºó×óÐý
|
||||||
* | 3 | < 0 | < 0 | ÓŇĐý
|
* | 3 | < -1 | < 0 | ÓÒÐý
|
||||||
* | 4 | < 0 | > 0 | ĎČÓŇĐýşó×óĐý
|
* | 4 | < -1 | > 0 | ÏÈÓÒÐýºó×óÐý
|
||||||
*
|
*
|
||||||
* @param self
|
* @param self
|
||||||
* @return true
|
* @return true
|
||||||
@ -1508,13 +1508,14 @@ static void tree_set_balance(struct _tree* self, struct _tree_node * node)
|
|||||||
static bool tree_avl_rebalance(struct _tree* self, struct _tree_node* root)
|
static bool tree_avl_rebalance(struct _tree* self, struct _tree_node* root)
|
||||||
{
|
{
|
||||||
assert(self != NULL);
|
assert(self != NULL);
|
||||||
if((root == NULL) || (root->left == NULL) || (root->right == NULL))
|
if(root == NULL)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tree_set_balance(self, root);
|
||||||
int balance = root->balance;
|
int balance = root->balance;
|
||||||
if(balance > 0)
|
if(balance > 1)
|
||||||
{
|
{
|
||||||
if(root->right->balance > 0)
|
if(root->right->balance > 0)
|
||||||
{
|
{
|
||||||
@ -1525,7 +1526,7 @@ static bool tree_avl_rebalance(struct _tree* self, struct _tree_node* root)
|
|||||||
root = tree_trun_left_then_right(self, root);
|
root = tree_trun_left_then_right(self, root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(balance < 0)
|
else if(balance < 1)
|
||||||
{
|
{
|
||||||
if(root->left->balance < 0)
|
if(root->left->balance < 0)
|
||||||
{
|
{
|
||||||
@ -1537,7 +1538,10 @@ static bool tree_avl_rebalance(struct _tree* self, struct _tree_node* root)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tree_set_balance(self, root);
|
if(root->parent != NULL)
|
||||||
|
{
|
||||||
|
tree_avl_rebalance(self, root->parent);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1665,6 +1669,7 @@ bool tree_avl_insert(struct _tree* self, void* obj)
|
|||||||
tree_node_free(node);
|
tree_node_free(node);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
self->rebalance(self, root);
|
||||||
}
|
}
|
||||||
|
|
||||||
self->_size++;
|
self->_size++;
|
||||||
|
Loading…
Reference in New Issue
Block a user