mirror of
https://gitee.com/openharmony/startup_init
synced 2025-03-01 17:08:26 +00:00
commit
1fe58187be
@ -261,16 +261,20 @@ void WatcherManagerKits::ParameterChangeListener::OnParameterChange(const std::s
|
||||
} // namespace init_param
|
||||
} // namespace OHOS
|
||||
|
||||
static int ParameterWatcherCheck(const char *keyPrefix)
|
||||
{
|
||||
std::string key(keyPrefix);
|
||||
if (key.rfind("*") == key.length() - 1) {
|
||||
return WatchParamCheck(key.substr(0, key.length() - 1).c_str());
|
||||
} else {
|
||||
return WatchParamCheck(keyPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
int SystemWatchParameter(const char *keyPrefix, ParameterChangePtr callback, void *context)
|
||||
{
|
||||
WATCHER_CHECK(keyPrefix != nullptr, return PARAM_CODE_INVALID_PARAM, "Invalid prefix");
|
||||
int ret = 0;
|
||||
std::string key(keyPrefix);
|
||||
if (key.rfind("*") == key.length() - 1) {
|
||||
ret = WatchParamCheck(key.substr(0, key.length() - 1).c_str());
|
||||
} else {
|
||||
ret = WatchParamCheck(keyPrefix);
|
||||
}
|
||||
int ret = ParameterWatcherCheck(keyPrefix);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
@ -286,13 +290,7 @@ int SystemWatchParameter(const char *keyPrefix, ParameterChangePtr callback, voi
|
||||
int RemoveParameterWatcher(const char *keyPrefix, ParameterChgPtr callback, void *context)
|
||||
{
|
||||
WATCHER_CHECK(keyPrefix != nullptr, return PARAM_CODE_INVALID_PARAM, "Invalid prefix");
|
||||
int ret = 0;
|
||||
std::string key(keyPrefix);
|
||||
if (key.rfind("*") == key.length() - 1) {
|
||||
ret = WatchParamCheck(key.substr(0, key.length() - 1).c_str());
|
||||
} else {
|
||||
ret = WatchParamCheck(keyPrefix);
|
||||
}
|
||||
int ret = ParameterWatcherCheck(keyPrefix);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ static void TestHashNodeFree(const HashNode *node)
|
||||
|
||||
static TestHashNode *TestCreateHashNode(const char *value)
|
||||
{
|
||||
TestHashNode *node = (TestHashNode *)malloc(sizeof(TestHashNode) + strlen(value) + 1);
|
||||
TestHashNode *node = reinterpret_cast<TestHashNode *>(malloc(sizeof(TestHashNode) + strlen(value) + 1));
|
||||
if (node == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -12,8 +12,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef PARAM_TEST_STUB_
|
||||
#define PARAM_TEST_STUB_
|
||||
#ifndef PARAM_TEST_STUB
|
||||
#define PARAM_TEST_STUB
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
Loading…
x
Reference in New Issue
Block a user