This is an automated email from the ASF dual-hosted git repository. pengzheng pushed a commit to branch feature/trim_string_in_place in repository https://gitbox.apache.org/repos/asf/celix.git
commit 8c403f847f3c4d0e8deb2c1f2759705280d90755 Author: PengZheng <[email protected]> AuthorDate: Sat May 6 17:44:47 2023 +0800 Recover proper use of celix_utils_trimInPlace. --- .../rsa_shm/src/rsa_shm_export_registration.c | 7 ++----- .../rsa_shm/src/rsa_shm_impl.c | 15 ++++----------- .../rsa_shm/src/rsa_shm_import_registration.c | 7 ++----- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_export_registration.c b/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_export_registration.c index 6e4b6b19..ecdd9ebd 100644 --- a/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_export_registration.c +++ b/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_export_registration.c @@ -113,11 +113,10 @@ celix_status_t exportRegistration_create(celix_bundle_context_t *context, char *token, *savePtr; token = strtok_r(icCopy, delimiter, &savePtr); while (token != NULL) { - rsaRpcType = celix_utils_trim(token); - if (rsaRpcType != NULL && strncmp(rsaRpcType, RSA_RPC_TYPE_PREFIX, sizeof(RSA_RPC_TYPE_PREFIX) - 1) == 0) { + rsaRpcType = celix_utils_trimInPlace(token); + if (strncmp(rsaRpcType, RSA_RPC_TYPE_PREFIX, sizeof(RSA_RPC_TYPE_PREFIX) - 1) == 0) { break; } - free(rsaRpcType); rsaRpcType = NULL; token = strtok_r(NULL, delimiter, &savePtr); } @@ -151,14 +150,12 @@ celix_status_t exportRegistration_create(celix_bundle_context_t *context, *exportOut = export; - free(rsaRpcType); free(icCopy); return CELIX_SUCCESS; tracker_err: rpc_type_filter_err: - free(rsaRpcType); rpc_type_err: free(icCopy); imported_configs_err: diff --git a/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_impl.c b/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_impl.c index 3f576066..1aba2590 100755 --- a/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_impl.c +++ b/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_impl.c @@ -293,14 +293,11 @@ static bool rsaShm_isConfigTypeMatched(celix_properties_t *properties) { token = strtok_r(ecCopy, delimiter, &savePtr); while (token != NULL) { - char *configType = celix_utils_trim(token); - if (configType != NULL && strncmp(configType, RSA_SHM_CONFIGURATION_TYPE, 1024) == 0) { + char *configType = celix_utils_trimInPlace(token); + if (strncmp(configType, RSA_SHM_CONFIGURATION_TYPE, 1024) == 0) { matched = true; - free(configType); break; } - free(configType); - token = strtok_r(NULL, delimiter, &savePtr); } @@ -657,17 +654,13 @@ celix_status_t rsaShm_importService(rsa_shm_t *admin, endpoint_description_t *en token = strtok_r(ecCopy, delimiter, &savePtr); while (token != NULL) { - char *trimmedToken = celix_utils_trim(token); - if (trimmedToken != NULL && strcmp(trimmedToken, RSA_SHM_CONFIGURATION_TYPE) == 0) { + char *trimmedToken = celix_utils_trimInPlace(token); + if (strcmp(trimmedToken, RSA_SHM_CONFIGURATION_TYPE) == 0) { importService = true; - free(trimmedToken); break; } - free(trimmedToken); - token = strtok_r(NULL, delimiter, &savePtr); } - free(ecCopy); } else { celix_logHelper_warning(admin->logHelper, "Mandatory %s element missing from endpoint description", OSGI_RSA_SERVICE_IMPORTED_CONFIGS); diff --git a/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_import_registration.c b/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_import_registration.c index 6c865cf2..88dddcae 100644 --- a/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_import_registration.c +++ b/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_import_registration.c @@ -76,11 +76,10 @@ celix_status_t importRegistration_create(celix_bundle_context_t *context, char *token, *savePtr; token = strtok_r(icCopy, delimiter, &savePtr); while (token != NULL) { - rsaRpcType = celix_utils_trim(token); - if (rsaRpcType != NULL && strncmp(rsaRpcType, RSA_RPC_TYPE_PREFIX, sizeof(RSA_RPC_TYPE_PREFIX) - 1) == 0) { + rsaRpcType = celix_utils_trimInPlace(token); + if (strncmp(rsaRpcType, RSA_RPC_TYPE_PREFIX, sizeof(RSA_RPC_TYPE_PREFIX) - 1) == 0) { break; } - free(rsaRpcType); rsaRpcType = NULL; token = strtok_r(NULL, delimiter, &savePtr); } @@ -113,13 +112,11 @@ celix_status_t importRegistration_create(celix_bundle_context_t *context, *importOut = import; - free(rsaRpcType); free(icCopy); return CELIX_SUCCESS; tracker_err: rpc_type_filter_err: - free(rsaRpcType); rpc_type_err: free(icCopy); imported_configs_err:
