From ec2cea06d21938ca22b1e85a61802c3d8c61eaf9 Mon Sep 17 00:00:00 2001 From: wangyikai Date: Thu, 12 Sep 2024 16:53:46 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90hdf=5Fcore=E3=80=91=E4=BD=BF=E7=94=A8d?= =?UTF-8?q?estructor=20=E9=87=8A=E6=94=BE=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangyikai --- adapter/uhdf2/host/devhost.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/adapter/uhdf2/host/devhost.c b/adapter/uhdf2/host/devhost.c index 0e782eda6..48c7e2d08 100644 --- a/adapter/uhdf2/host/devhost.c +++ b/adapter/uhdf2/host/devhost.c @@ -157,6 +157,7 @@ static void SetHostProperties(int argc, char **argv, const char *hostName) } } +struct IDevHostService *g_instance = NULL; int main(int argc, char **argv) { if (argc < DEVHOST_MIN_INPUT_PARAM_NUM) { @@ -173,6 +174,7 @@ int main(int argc, char **argv) HDF_LOGI("hdf device host %{public}s %{public}d start", hostName, hostId); SetHostProperties(argc, argv, hostName); struct IDevHostService *instance = DevHostServiceNewInstance(hostId, hostName); + g_instance = instance; if (instance == NULL || instance->StartService == NULL) { HDF_LOGE("DevHostServiceGetInstance fail"); return HDF_ERR_INVALID_OBJECT; @@ -202,3 +204,10 @@ int main(int argc, char **argv) } return status; } + +__attribute__((destructor)) void ReleaseInstance() +{ + if (g_instance != NULL) { + DevHostServiceFreeInstance(g_instance); + } +} -- Gitee