diff --git a/interfaces/kits/cj/BUILD.gn b/interfaces/kits/cj/BUILD.gn index 31cbee11f5f1747a0e14b8250ba50aa541369665..faa8e70301887535c45be84b01f6e6dc32f004d1 100644 --- a/interfaces/kits/cj/BUILD.gn +++ b/interfaces/kits/cj/BUILD.gn @@ -29,8 +29,6 @@ ohos_shared_library("cj_config_policy_ffi") { "bounds_checking_function:libsec_shared", "hilog:libhilog", "hisysevent:libhisysevent", - "napi:cj_bind_ffi", - "napi:cj_bind_native", ] sources = [ "../../../frameworks/dfx/hisysevent_adapter/hisysevent_adapter.cpp", diff --git a/interfaces/kits/cj/src/config_policy_ffi.cpp b/interfaces/kits/cj/src/config_policy_ffi.cpp index 3af9e30f524d2cb74e79ae3bcc3776dab0e32f09..6997cd810dfa055c647c6b636fef066fe1861bbc 100644 --- a/interfaces/kits/cj/src/config_policy_ffi.cpp +++ b/interfaces/kits/cj/src/config_policy_ffi.cpp @@ -31,7 +31,7 @@ char** MallocCStringArr(const std::vector& origin) return nullptr; } auto size = origin.size(); - if (size == 0 || size > MAX_MALLOC_LEN) { + if (size > MAX_MALLOC_LEN) { return nullptr; } auto arr = static_cast(malloc(sizeof(char*) * size)); diff --git a/interfaces/kits/cj/src/config_policy_ffi.h b/interfaces/kits/cj/src/config_policy_ffi.h index 17ffea9fa12915e408b6b9a2f61a2876c99d9b7b..29e6c8d9bdc12f9fe3e36ff70ecc4c57d30f7ad5 100644 --- a/interfaces/kits/cj/src/config_policy_ffi.h +++ b/interfaces/kits/cj/src/config_policy_ffi.h @@ -16,10 +16,27 @@ #ifndef CONFIG_POLICY_FFI_H #define CONFIG_POLICY_FFI_H -#include "ffi_remote_data.h" -#include "cj_common_ffi.h" +#include + +#define FFI_EXPORT __attribute__((visibility("default"))) extern "C" { + const int32_t SUCCESS_CODE = 0; + struct CArrString { + char** head; + int64_t size; + }; + + struct RetDataCArrString { + int32_t code; + CArrString data; + }; + + struct RetDataCString { + int32_t code; + char* data; + }; + FFI_EXPORT RetDataCArrString CJ_GetCfgDirList(); FFI_EXPORT RetDataCArrString CJ_GetCfgFiles(const char* relPath); FFI_EXPORT RetDataCString CJ_GetOneCfgFile(const char* relPath);