From eed0e6e3c6124009fc5d6a0e33b9a05075f6eeac Mon Sep 17 00:00:00 2001 From: qq_35037212 Date: Thu, 21 Aug 2025 15:51:28 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8Dstring=20malloc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fangwusheng@h-partners.com --- .../cj/work_scheduler/work_scheduler_ffi.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/interfaces/kits/cj/work_scheduler/work_scheduler_ffi.cpp b/interfaces/kits/cj/work_scheduler/work_scheduler_ffi.cpp index efbf026..89faad7 100644 --- a/interfaces/kits/cj/work_scheduler/work_scheduler_ffi.cpp +++ b/interfaces/kits/cj/work_scheduler/work_scheduler_ffi.cpp @@ -26,6 +26,21 @@ namespace OHOS { namespace WorkScheduler { +int32_t InnerWrapWantParamsString(const sptr iIt, CParameters *p) +{ + AAFwk::IString *ao = AAFwk::IString::Query(iIt); + if (ao == nullptr) { + LOGE("ao is nullptr, no memory."); + return ERR_NO_MEMORY; + } + + std::string natValue = OHOS::AAFwk::String::Unbox(ao); + p->value = MallocCString(natValue); + p->size = static_cast(natValue.length()) + 1; + p->valueType = STRING_TYPE; + return 0; +} + template int32_t InnerWrapWantParamsT(const sptr iIt, CParameters *p) { @@ -462,7 +477,7 @@ extern "C" { } case VALUE_TYPE_STRING: { arrParam.head[i].valueType = STRING_TYPE; - InnerWrapWantParamsT(it.second, &arrParam.head[i]); + InnerWrapWantParamsString(it.second, &arrParam.head[i]); break; } default: { -- Gitee