improve conf_node_set_value

This commit is contained in:
lixianjing 2023-10-21 18:42:00 +08:00
parent 1d671d9343
commit 609e15b90b

View File

@ -483,20 +483,26 @@ ret_t conf_node_set_value(conf_node_t* node, const value_t* v) {
return_value_if_fail(node->value_type != CONF_NODE_VALUE_NODE, RET_BAD_PARAMS);
if (node->value_type == CONF_NODE_VALUE_STRING) {
const char* p = value_str(v);
if (node->value.str == p && p != NULL) {
return RET_OK;
if (v->type == VALUE_TYPE_STRING) {
const char* p = value_str(v);
if (node->value.str == p && p != NULL) {
return RET_OK;
}
}
TKMEM_FREE(node->value.str);
} else if (node->value_type == CONF_NODE_VALUE_SMALL_STR) {
const char* p = value_str(v);
if (node->value.small_str == p && p != NULL) {
return RET_OK;
if (v->type == VALUE_TYPE_STRING) {
const char* p = value_str(v);
if (node->value.small_str == p && p != NULL) {
return RET_OK;
}
}
} else if (node->value_type == CONF_NODE_VALUE_WSTRING) {
const wchar_t* p = value_wstr(v);
if (node->value.wstr == p && p != NULL) {
return RET_OK;
if (v->type == VALUE_TYPE_WSTRING) {
const wchar_t* p = value_wstr(v);
if (node->value.wstr == p && p != NULL) {
return RET_OK;
}
}
TKMEM_FREE(node->value.wstr);
}
@ -1115,7 +1121,7 @@ int32_t conf_node_get_child_value_int32(conf_node_t* node, const char* name, int
value_t v;
return_value_if_fail(node != NULL && name != NULL, defval);
if(conf_node_get_child_value(node, name, &v) == RET_OK) {
if (conf_node_get_child_value(node, name, &v) == RET_OK) {
return value_int32(&v);
} else {
return defval;
@ -1126,7 +1132,7 @@ bool_t conf_node_get_child_value_bool(conf_node_t* node, const char* name, bool_
value_t v;
return_value_if_fail(node != NULL && name != NULL, defval);
if(conf_node_get_child_value(node, name, &v) == RET_OK) {
if (conf_node_get_child_value(node, name, &v) == RET_OK) {
return value_bool(&v);
} else {
return defval;
@ -1137,7 +1143,7 @@ const char* conf_node_get_child_value_str(conf_node_t* node, const char* name, c
value_t v;
return_value_if_fail(node != NULL && name != NULL, defval);
if(conf_node_get_child_value(node, name, &v) == RET_OK) {
if (conf_node_get_child_value(node, name, &v) == RET_OK) {
return value_str(&v);
} else {
return defval;